liveservices/LiveSDK-for-Android

Store access token

whoisprakhar opened this issue · 5 comments

I wanted to know that if there is a way to initialize the client with access-token provided by session class, so that i don't have to make user login multiple times ? Any help will be appreciated! :)

Not sure what your scenario is, are you looking to have an application that allows a user to sign in with multiple OneDrive accounts? The sample as provide will keep login credentials for one account within the Android Account store; however the LiveSDKs do not support 'Single Sign On' with the OneDrive application or other Microsoft applications.

i haven't seen any android account store usage in the sample?

Oops, let me correct myself, we do not use the account manager within the LiveSDK, we store a 'refresh token' within a private SharedPreferences object under the name 'com.microsoft.live', which would be bound to your applications APK. This token has an expirery set during the original authentication call.

Provided that you call LiveAuthClient#initialize(...) on your applications start you will receive a notification via the LiveAuthListener that the stored token is still valid (after a network request confirms this) with a status code of LiveStatus.CONNECTED.

This should be able to persist the sign in state between the application start/stops.

awesome! Btw if it expires is there a way to refresh it or sdk does it automatically ?

If that response object from the LiveAuthClient comes back with something other than LiveStatus.CONNECTED, then you'll want to have the user sign in again. If you poke around at the sample application's SignInActivity this is pretty much what it is built to handle along with a little UX