Question

I develop an android application which use OneDrive API. When I connect to OneDrive, it asks me to authenticate and show an authorization page (with permission to access to my data on the cloud).

My problem is : Every time I upload data on the cloud, the application shows me the authorization page. I would like this page to not appear every time. How can we find that it already recorded please ?

Thank a lot !

Was it helpful?

Solution

When using the LiveSDK for Andriod, there is an assumption that the user is authenticated at all times when using the application, in order to preserve this flow, we require that you call LiveAuthClient.initialize(...) to renew the user credentials (without any user input) or call LiveAuthClient.login(...) in order to perform an interactive login (User entering username/password).

In the LiveSDK sample apps we see this implemented with a startup activity called SignInActivity.java Here are the relevant excerpts to perform the silent credentials renewal:

protected void onStart() {
   super.onStart();
   mAuthClient.initialize(Arrays.asList(Config.SCOPES), new LiveAuthListener() {
      @Override
      public void onAuthError(LiveAuthException exception, Object userState) {
         mInitializeDialog.dismiss();
         showSignIn();
         showToast(exception.getMessage());
      }

      @Override
      public void onAuthComplete(LiveStatus status, LiveConnectSession session, Object userState) {
         mInitializeDialog.dismiss();
         if (status == LiveStatus.CONNECTED) {
            launchMainActivity(session);
         } else {
            showSignIn();
         }
      }
   });
}

The launchMainActivity() function moves the user into the primary application code, this would be where your application starts in earnest. To see the full details of this sign in activity take a look at the sample app SignInActivity.java in Github

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top