Android Emulator Authentication failed
See original GitHub issueI have faced really strange issue with authorization. For newly created emulator login finishes with success, but next logins are failing. I am reporting this issue just because using real device does not face such issue.
E/AuthenticationManager$a: Authentication failed
com.microsoft.identity.client.MsalClientException: Auth failed with the error null
at com.microsoft.identity.client.BaseRequest.performTokenRequest(BaseRequest.java:184)
at com.microsoft.identity.client.BaseRequest$1.run(BaseRequest.java:111)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.io.EOFException
at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:95)
at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:179)
at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:101)
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:628)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:388)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:199)
at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
at com.microsoft.identity.client.HttpRequest.executeHttpSend(HttpRequest.java:191)
at com.microsoft.identity.client.HttpRequest.sendWithRetry(HttpRequest.java:157)
at com.microsoft.identity.client.HttpRequest.send(HttpRequest.java:138)
at com.microsoft.identity.client.HttpRequest.sendPost(HttpRequest.java:114)
at com.microsoft.identity.client.Oauth2Client.executeHttpRequest(Oauth2Client.java:142)
at com.microsoft.identity.client.Oauth2Client.getToken(Oauth2Client.java:77)
at com.microsoft.identity.client.BaseRequest.performTokenRequest(BaseRequest.java:180)
at com.microsoft.identity.client.BaseRequest$1.run(BaseRequest.java:111)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Firebase Authentication failing on android emulators due to ...
1 Answer 1 · Open the Android Virtual Device (AVD) Manager in Android Studio. · Click on "Create Virtual Device..." · Select one...
Read more >Troubleshoot known issues with Android Emulator
If the emulator fails to launch due to the error vulkan-1.dll cannot be found , you probably need to update the emulator. To...
Read more >Get Started with Firebase Authentication on Android
An Authentication emulator is part of the Local Emulator Suite, which enables your app to ... makeText(EmailPasswordActivity.this, "Authentication failed.
Read more >How to Fix the “Google Play Authentication Is Required” Error ...
Play Store's “Authentication is required” error sometimes appears out of nowhere and prevents you from getting your favorite apps or games ...
Read more >Authentication Failed in emulator and device - SAP Community
When you are creating/registering user for the Android device give your SUP server IP (try with private IP) and check in the device...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am pretty sure this is caused by: File:
common/src/main/java/com/microsoft/identity/common/internal/net/HttpRequest.java
(line ~212) Code:urlConnection.setRequestProperty("Connection", "close");
This code is executed in all recent releases of com.microsoft.identity:common up to the most recent release (as of this writing: v0.0.9). If I comment out this statement, I no longer get
error unexpected end of stream on com.android.okhttp.Address
while running MSAL in emulation.Someone already commented out this code in :common branch ‘dev’: https://github.com/AzureAD/microsoft-authentication-library-common-for-android/commit/bd8d4b8607970c86af893598e04c1188f3a4c942 so I guess we’ll just wait to see if it gets merged into a release.
Strictly speaking this is probably not an :msal/:common bug, but rather an “okhttp in combination with Android emulation’s TCP/IP quirks” bug. However, if nobody knows of a good reason to set the (“Connection”, “close”) request header, then maybe remove it for the sake of developers working with MSAL in emulation. Besides, connection reuse is good on mobile!
Edit: Apologies to iambmelt. I missed their earlier comment where they mention the same line of code.
This is removed for the next release