OneDrive / onedrive-sdk-android

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

Bug in the authentication for API < 18. #109

Closed isabsent closed 1 month ago

isabsent commented 8 years ago

I am trying to use OneDrive SDK with API 16 device by means of:

compile ('com.onedrive.sdk:onedrive-sdk-android:1.3.0') {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')

As a result I have

E/Trace: error opening trace file: Permission denied (13)
E/dalvikvm: Could not find class 'android.security.KeyPairGeneratorSpec$Builder', referenced from method com.microsoft.aad.adal.StorageHelper.getKeyPairGeneratorSpec
E/ACRA: ACRA caught a IllegalStateException for com.jetico.bestcrypt
    java.lang.IllegalStateException: Secret key must be provided for API < 18. Use AuthenticationSettings.INSTANCE.setSecretKey()
      at com.microsoft.aad.adal.StorageHelper.loadSecretKeyForAPI(StorageHelper.java:152)
      at com.microsoft.aad.adal.DefaultTokenCacheStore.<init>(DefaultTokenCacheStore.java:103)
      at com.microsoft.aad.adal.AuthenticationContext.<init>(AuthenticationContext.java:152)
      at com.onedrive.sdk.authentication.ADALAuthenticator.init(ADALAuthenticator.java:206)
      at com.onedrive.sdk.authentication.DisambiguationAuthenticator.init(DisambiguationAuthenticator.java:130)
      at com.onedrive.sdk.extensions.OneDriveClient$Builder.loginAndBuildClient(OneDriveClient.java:163)
      at com.onedrive.sdk.extensions.OneDriveClient$Builder.access$500(OneDriveClient.java:64)
      at com.onedrive.sdk.extensions.OneDriveClient$Builder$1.run(OneDriveClient.java:147)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
      at java.lang.Thread.run(Thread.java:856)

What does it mean Use AuthenticationSettings.INSTANCE.setSecretKey() and how to avoid this error? Is it a contradiction with "Supported Android Versions 15" for this SDK?

daboxu commented 8 years ago

yup, I think I need to bump the minimum version to 18 as ADAL does not support lower version anymore. Will this impact your story hugely? I saw stat on Android website and it seems it would not be very harmful: https://developer.android.com/about/dashboards/index.html

isabsent commented 8 years ago

I have solved the problem by using

DefaultClientConfig.createWithAuthenticator(msaAuthenticator)

itstead of

DefaultClientConfig.createWithAuthenticators(msaAuthenticator, adalAuthenticator)

If I do not use adalAuthenticator I do not get "Secret key must be provided for API < 18" message for API >= 14 and this API level is enough for my purposes.

baywet commented 1 month ago

Thank you for reaching out and for your patience. This SDK is being officially deprecated. See #172 for more information