i am using live sdk for integrating onedrive in my Android app i want to know that if there is a method which can initialize the client with access-token or is there any way by which i don't have to make user login multiple times, like in dropbox sdk. any help will be highly appreciated, Thank You!
1
votes
"make user login multiple times" do you mean multiple times within your application or other applications on the device that also using a Microsoft account?
– Peter Nied
I think it mean within same application, as I need something similar. The thing is that I am able to sign using live sdk, and get access token inside onAuthComplete but I don't know how to reuse it. For example in Dropbox API you can use setOAuth2AccessToken(accessToken); to obtain permissions after once accepted (when signed in at login activity or somewhere)
– DoubleK
1 Answers
2
votes
auth = new LiveAuthClient(this, AppConnectionSettings.ONE_DRIVE_APP_CLIENT_ID); // private LiveAuthClient auth; - class member
SharedPreferences prefs = getSharedPreferences(AppSettings.ONE_DRIVE_PREFS_NAME, Context.MODE_PRIVATE);
String refreshToken = prefs.getString(AppConnectionSettings.ONE_DRIVE_REFRESH_TOKEN_KEY, null); // save it to shared preferences on first login
LiveAuthListener liveAuthListener = (LiveAuthListener) this;
Object userState = new Object();
auth.initialize(scopes, liveAuthListener, userState, refreshToken);
Finally I found a solution :)