OneDrive / onedrive-sdk-android

OneDrive SDK for Android!
https://dev.onedrive.com
Other
148 stars 52 forks source link

Can't login with MSA Authenticator on Lenovo Vibe Shot (Android 6.0.1) #115

Closed isabsent closed 7 years ago

isabsent commented 7 years ago

I have faced with a very strange situation on Lenovo Vibe Shot Z90a40 (Android 6.0.1) device. When I try to login to OneDrive (not a Bussiness Cloud) with

SCOPES_ARRAY = new String[] {"onedrive.readwrite", "onedrive.appfolder", "wl.offline_access"};    

it does not show me login screen - just a white screen without any content. In the logcat I see:

I/LiveAuthClient: No refresh token available, sorry!
I/LiveAuthClient: All tokens expired, you need to call login() to initiate interactive logon
E/MSAAuthenticator$5[onAuthComplete] - 314: Failed silent login, interactive login required
    com.onedrive.sdk.authentication.ClientAuthenticatorException: Failed silent login, interactive login required
        at com.onedrive.sdk.authentication.MSAAuthenticator$5.onAuthComplete(MSAAuthenticator.java:312)
        at com.microsoft.services.msa.LiveAuthClient$3.doInBackground(LiveAuthClient.java:484)
        at com.microsoft.services.msa.LiveAuthClient$3.doInBackground(LiveAuthClient.java:473)
        at android.os.AsyncTask$2.call(AsyncTask.java:295)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)
I/LiveAuthClient: No refresh token available, sorry!
I/LiveAuthClient: All tokens expired, you need to call login() to initiate interactive logon
I/WebViewFactory: Loading com.google.android.webview version 53.0.2785.124 (code 278512450)
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
I/cr_LibraryLoader: Time to load native libraries: 1 ms (timestamps 3243-3244)
I/cr_LibraryLoader: Expected native library version number "53.0.2785.124", actual native library version number "53.0.2785.124"
V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {f817a3f}
I/cr_LibraryLoader: Expected native library version number "53.0.2785.124", actual native library version number "53.0.2785.124"
I/chromium: [INFO:library_loader_hooks.cc(151)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_BrowserStartup: Initializing chromium process, singleProcess=true
W/cr_media: Requires BLUETOOTH permission
W/cr_AwContents: onDetachedFromWindow called when already detached. Ignoring
I/cr_Ime: ImeThread is not enabled.
I/ActivityThread: Dispatching broadcast android.net.conn.CONNECTIVITY_CHANGE to org.chromium.net.NetworkChangeNotifierAutoDetect@995eb3
D/ActivityThread: BDC-Calling onReceive end receiver=class org.chromium.net.NetworkChangeNotifierAutoDetect
E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
I/ActivityThread: Dispatching broadcast android.net.conn.CONNECTIVITY_CHANGE to org.chromium.net.NetworkChangeNotifierAutoDetect@7e7f12b
D/ActivityThread: BDC-Calling onReceive end receiver=class org.chromium.net.NetworkChangeNotifierAutoDetect
W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2
W/VideoCapabilities: Unrecognized profile/level 0/3 for video/mpeg2
W/VideoCapabilities: Unsupported mime video/x-ms-wmv
W/VideoCapabilities: Unsupported mime video/divx
W/VideoCapabilities: Unsupported mime video/divx311
W/VideoCapabilities: Unsupported mime video/divx4
W/VideoCapabilities: Unsupported mime video/mp4v-esdp
I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 21094
W/WebKit: A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26754.00.1/DefaultLoginPaginatedStrings.RU.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.
I/chromium: [INFO:CONSOLE(8)] "A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26754.00.1/DefaultLoginPaginatedStrings.RU.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.", source: https://login.live.com/oauth20_authorize.srf?client_id=0000000040174952&scope=onedrive.appfolder%20onedrive.readwrite%20wl.offline_access&display=android_phone&response_type=code&redirect_uri=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf (8)
W/WebKit: A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26754.00.1/DefaultLoginPaginatedStrings.RU.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.
I/chromium: [INFO:CONSOLE(8)] "A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26754.00.1/DefaultLoginPaginatedStrings.RU.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.", source: https://login.live.com/oauth20_authorize.srf?client_id=0000000040174952&scope=onedrive.appfolder%20onedrive.readwrite%20wl.offline_access&display=android_phone&response_type=code&redirect_uri=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf (8)
W/WebKit: A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26754.00.1/DefaultLogin_PCore.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.
I/chromium: [INFO:CONSOLE(8)] "A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26754.00.1/DefaultLogin_PCore.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.", source: https://login.live.com/oauth20_authorize.srf?client_id=0000000040174952&scope=onedrive.appfolder%20onedrive.readwrite%20wl.offline_access&display=android_phone&response_type=code&redirect_uri=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf (8)

On other device (and emulator with Android 6.0 Google APIs ) MSA authentication works fine (code is the same as for Lenovo) and logcat is:

I/LiveAuthClient: No refresh token available, sorry!
I/LiveAuthClient: All tokens expired, you need to call login() to initiate interactive logon
I/WebViewFactory: Loading com.android.webview version 44.0.2403.119 (code 246011910)
E/MSAAuthenticator$5[onAuthComplete] - 314: Failed silent login, interactive login required
    com.onedrive.sdk.authentication.ClientAuthenticatorException: Failed silent login, interactive login required
        at com.onedrive.sdk.authentication.MSAAuthenticator$5.onAuthComplete(MSAAuthenticator.java:312)
        at com.microsoft.services.msa.LiveAuthClient$3.doInBackground(LiveAuthClient.java:484)
        at com.microsoft.services.msa.LiveAuthClient$3.doInBackground(LiveAuthClient.java:473)
        at android.os.AsyncTask$2.call(AsyncTask.java:295)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)
I/LiveAuthClient: No refresh token available, sorry!
I/LiveAuthClient: All tokens expired, you need to call login() to initiate interactive logon
W/System: ClassLoader referenced unknown path: /system/app/webview/lib/x86
I/LibraryLoader: Time to load native libraries: 1 ms (timestamps 5396-5397)
I/LibraryLoader: Expected native library version number "",actual native library version number ""
V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {4925404}
I/LibraryLoader: Expected native library version number "",actual native library version number ""
I/chromium: [INFO:library_loader_hooks.cc(120)] Chromium logging enabled: level = 0, default verbosity = 0
I/BrowserStartupController: Initializing chromium process, singleProcess=true
W/art: Attempt to remove non-JNI local reference, dumping thread
E/SysUtils: ApplicationContext is null in ApplicationStatus
W/chromium: [WARNING:resource_bundle.cc(285)] locale_file_path.empty()
E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
W/AudioManagerAndroid: Requires BLUETOOTH permission
E/DataReductionProxySettingListener: No DRP key due to exception:java.lang.ClassNotFoundException: com.android.webview.chromium.Drp
W/art: Attempt to remove non-JNI local reference, dumping thread
W/AwContents: onDetachedFromWindow called when already detached. Ignoring
W/chromium: [WARNING:data_reduction_proxy_config.cc(423)] SPDY proxy OFF at startup
E/EGL_emulation: tid 22389: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa02bf5e0, error=EGL_BAD_MATCH
E/emuglGLESv2_enc: device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glVertexAttribPointer:291 GL error 0x501
W/BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 22353
W/BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 22353

In the build.gradle I have:

...
compile ('com.onedrive.sdk:onedrive-sdk-android:1.3.1') {transitive = false}
compile ('com.google.code.gson:gson:2.3.1')
compile ('com.microsoft.services.msa:msa-auth:0.8.6')
compile ('com.microsoft.aad:adal:1.1.19')
...

Why login screen does not appear?

P.S. Message "This may be blocked by the browser if the device has poor network connectivity" in the first logcat is very strange because Lenovo device has 20 Mbps download and upload speed over WiFi at this moment (measured by Speedtest app).

IvanShafran commented 7 years ago

@isabsent The same problem on Asus ZenPad 8 (Android 6.0.1) :(

isabsent commented 7 years ago

@IvanShafran Can you paste the log of unsuccessful authorization here?

IvanShafran commented 7 years ago

@isabsent

 I/LiveAuthClient: No refresh token available, sorry!
 I/LiveAuthClient: All tokens expired, you need to call login() to initiate interactive logon
 E/MSAAuthenticator$5[onAuthComplete] - 314: Failed silent login, interactive login required
   com.onedrive.sdk.authentication.ClientAuthenticatorException: Failed silent login, interactive login required
      at com.onedrive.sdk.authentication.MSAAuthenticator$5.onAuthComplete(MSAAuthenticator.java:312)
      at com.microsoft.services.msa.LiveAuthClient$3.doInBackground(LiveAuthClient.java:484)
      at com.microsoft.services.msa.LiveAuthClient$3.doInBackground(LiveAuthClient.java:473)
      at android.os.AsyncTask$2.call(AsyncTask.java:295)
      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
      at java.lang.Thread.run(Thread.java:818)
 I/LiveAuthClient: No refresh token available, sorry!
 I/LiveAuthClient: All tokens expired, you need to call login() to initiate interactive logon
 I/WebViewFactory: Loading com.google.android.webview version 53.0.2785.124 (code 278512400)
 D/WebViewFactory: primaryArchIs64bit = false
 I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
 I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
 I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
 I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
 I/cr_LibraryLoader: Time to load native libraries: 2 ms (timestamps 5889-5891)
 I/cr_LibraryLoader: Expected native library version number "53.0.2785.124", actual native library version number "53.0.2785.124"
 V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {8714ac3}
 I/cr_LibraryLoader: Expected native library version number "53.0.2785.124", actual native library version number "53.0.2785.124"
 I/chromium: [INFO:library_loader_hooks.cc(151)] Chromium logging enabled: level = 0, default verbosity = 0
 I/cr_BrowserStartup: Initializing chromium process, singleProcess=true
 W/cr_media: Requires BLUETOOTH permission
 W/cr_AwContents: onDetachedFromWindow called when already detached. Ignoring
 I/cr_Ime: ImeThread is not enabled.
 I/Choreographer: Skipped 48 frames!  The application may be doing too much work on its main thread.
 E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
 W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
 W/AudioCapabilities: Unsupported mime audio/dts
 W/VideoCapabilities: Unsupported mime video/mp4v-esdp
 W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 3610
 W/WebKit: A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26893.00/DefaultLoginPaginatedStrings.EN-GB.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.
 W/WebKit: A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26893.00/DefaultLoginPaginatedStrings.EN-GB.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.
 I/chromium: [INFO:CONSOLE(8)] "A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26893.00/DefaultLoginPaginatedStrings.EN-GB.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.", source: https://login.live.com/oauth20_authorize.srf?client_id=f03c227e-933e-46f1-a014-38c675d834c5&scope=onedrive.readwrite&display=android_tablet&response_type=code&redirect_uri=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf (8)
 W/WebKit: A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26893.00/DefaultLogin_PCore.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.
 I/chromium: [INFO:CONSOLE(8)] "A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26893.00/DefaultLoginPaginatedStrings.EN-GB.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.", source: https://login.live.com/oauth20_authorize.srf?client_id=f03c227e-933e-46f1-a014-38c675d834c5&scope=onedrive.readwrite&display=android_tablet&response_type=code&redirect_uri=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf (8)
 I/chromium: [INFO:CONSOLE(8)] "A Parser-blocking, cross-origin script, https://auth.gfx.ms/16.000.26893.00/DefaultLogin_PCore.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.", source: https://login.live.com/oauth20_authorize.srf?client_id=f03c227e-933e-46f1-a014-38c675d834c5&scope=onedrive.readwrite&display=android_tablet&response_type=code&redirect_uri=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf (8)
 I/art: Background partial concurrent mark sweep GC freed 87713(5MB) AllocSpace objects, 9(320KB) LOS objects, 59% free, 8MB/20MB, paused 1.612ms total 170.120ms

And my gradle:

compile ('com.onedrive.sdk:onedrive-sdk-android:1.2+') {
     transitive = false
 }
compile ('com.google.code.gson:gson:2.3.1')

compile ('com.microsoft.services.msa:msa-auth:0.8.+')
compile ('com.microsoft.aad:adal:1.1.+')
daboxu commented 7 years ago

@isabsent @IvanShafran hi have you tried with other 6.0.1 devices? I used Nexus 5 with Android 6.0.1 and could not reproduce it.

isabsent commented 7 years ago

I have Lenovo Vibe Shot with Android 6.0.1 only and emulator. The problem is absent on the emulator and definetely the problem exists on Lenovo. I will try to find other device with 6.0.1. Do above logs have something useful for understanding of a problem?

daboxu commented 7 years ago

@isabsent I searched on the internet for a while and it seems related to the chromium package is not included as other users reported the 'Rejecting re-init on previously-failed class' log in other packages: https://github.com/realm/realm-java/issues/1990 http://stackoverflow.com/questions/32243791/unity-android-with-appcompat-rejecting-re-init-on-previously-failed-class-java-l

and specifically for the chromium webview, it seems it is related to specific hardware as you can see a similar question here: https://bugs.chromium.org/p/chromium/issues/detail?id=576252

isabsent commented 7 years ago

Is it possible to do not use webview in your Authenticator?

anishhegdeSE commented 7 years ago

I got a similar issue on Samsung Galaxy S5. On tapping on Login, the screen would go blank. Looking at @daboxu 's answer I went ahead and updated the WebView on the device and voila! it worked.

daboxu commented 7 years ago

@isabsent the webview is from the MSA Authenticator 'com.microsoft.services.msa:msa-auth:0.8.+' which we don't have plan right now to upgrade it. @anishhegdeSE glad to hear it works, could you mind sharing more info about your solution?

isabsent commented 7 years ago

As I understand from @anishhegdeSE answer it is necessary to update preinstalled WebView from Google Play. It works for Lenovo Vibe Shot too!

Is it possible to write a ticket to MSA Authenticator developers to check WebView version and ask user to update it if needed?

daboxu commented 7 years ago

I see, I will close this issue for now as there is a solution for it. Feel free to reopen it if necessary.

isabsent commented 7 years ago

Is it possible to write a ticket to MSA Authenticator developers to check WebView version and ask user to update it if needed?

daboxu commented 7 years ago

@isabsent I would argue with including this check into the Authenticator package, as stated in the Play Store

Android WebView is a system component powered by Chrome that allows Android apps to display web content. This component is pre-installed on your device and should be kept up to date to ensure you have the latest security updates and other bug fixes.

if this logic could be done in your app that would make more sense for me, and I am not sure how many devices have been affected and we want the SDK for general use purpose.