-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
Description
Description
Every few launches, I get an UnknownHostException and the following stacktrace:
Exception in thread "main" java.lang.RuntimeException: java.net.UnknownHostException: login.live.com
at fr.litarvan.openauth.microsoft.HttpClient.readResponse(HttpClient.java:147)
at fr.litarvan.openauth.microsoft.HttpClient.getText(HttpClient.java:52)
at fr.litarvan.openauth.microsoft.MicrosoftAuthenticator.preAuthRequest(MicrosoftAuthenticator.java:235)
at fr.litarvan.openauth.microsoft.MicrosoftAuthenticator.loginWithCredentials(MicrosoftAuthenticator.java:105)
at Start.main(Start.java:24)
Caused by: java.net.UnknownHostException: login.live.com
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1952)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1947)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1946)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1516)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1500)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
at fr.litarvan.openauth.microsoft.HttpClient.readResponse(HttpClient.java:114)
... 4 more
Caused by: java.net.UnknownHostException: login.live.com
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:607)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:293)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:203)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1207)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:189)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1572)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1500)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:3063)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderField(HttpsURLConnectionImpl.java:305)
at fr.litarvan.openauth.microsoft.HttpClient.readResponse(HttpClient.java:105)
... 4 more
Expected behavior
It should work
My code
MicrosoftAuthenticator authenticator = new MicrosoftAuthenticator();
MicrosoftAuthResult result = null;
String username = "DevUser";
String accessToken = " ";
String uuid = "0";
try {
result = authenticator.loginWithCredentials(..., ...);
username = result.getProfile().getName();
accessToken = result.getAccessToken();
uuid = result.getProfile().getId();
} catch (MicrosoftAuthenticationException e) {
e.printStackTrace();
}
System.out.printf("Logged in as '%s'\n", username);