Search code examples
androidappauth

AppAuth Relogin


After some back and forth I finally got this to work but I had to use version 0.2.0 because I followed the google guide presented in the Readme.

Anyway, Im struggling with handling what will happen when the oAuth token times out. Then it needs to open the browser again to log in or is there a background process available for this as it automatically redirects back to the app because the server remembers the user so there is no need for a new username/password input?

Im getting a refresh token like this :

if(mAuthService == null){
      mAuthService = new AuthorizationService(context);
 }
mAuthState.performActionWithFreshTokens(mAuthService, new AuthState.AuthStateAction() {
  @Override public void execute(
      String accessToken,
      String idToken,
      AuthorizationException ex) {
    if (ex != null) {
      return;
    }
    // Getting the access token...
  }
});

Thats working fine but after the user is idle for some time it wont work. How to handle this properly?


Solution

  • Solution for my problem was this:

    I changed to using offline_access for the token in the scope. Depending on the site/service you're login into if they accept it or not. For me it was accepted and will keep the user logged in for a long time and removes the need to re-login.