public void getCredentials(@NonNull final BaseCallback<Credentials, CredentialsManagerException> callback) {
        String accessToken = storage.retrieveString(KEY_ACCESS_TOKEN);
        final String refreshToken = storage.retrieveString(KEY_REFRESH_TOKEN);
        String idToken = storage.retrieveString(KEY_ID_TOKEN);
        String tokenType = storage.retrieveString(KEY_TOKEN_TYPE);
        Long expiresAt = storage.retrieveLong(KEY_EXPIRES_AT);
        String scope = storage.retrieveString(KEY_SCOPE);

        if (isEmpty(accessToken) && isEmpty(idToken) || expiresAt == null) {
            callback.onFailure(new CredentialsManagerException("No Credentials were previously set."));
            return;
        }
        if (expiresAt > getCurrentTimeInMillis()) {
            callback.onSuccess(recreateCredentials(idToken, accessToken, tokenType, refreshToken, new Date(expiresAt), scope));
            return;
        }
        if (refreshToken == null) {
            callback.onFailure(new CredentialsManagerException("Credentials have expired and no Refresh Token was available to renew them."));
            return;
        }

        authClient.renewAuth(refreshToken).start(new AuthenticationCallback<Credentials>() {
            @Override
            public void onSuccess(Credentials fresh) {
                //RefreshTokens don't expire. It should remain the same
                Credentials credentials = new Credentials(fresh.getIdToken(), fresh.getAccessToken(), fresh.getType(), refreshToken, fresh.getExpiresAt(), fresh.getScope());
                saveCredentials(credentials);
                callback.onSuccess(credentials);
            }

            @Override
            public void onFailure(AuthenticationException error) {
                callback.onFailure(new CredentialsManagerException("An error occurred while trying to use the Refresh Token to renew the Credentials.", error));
            }
        });
    }
public void getCredentials ( @ NonNull final BaseCallback < Credentials , CredentialsManagerException > callback ) { String accessToken = storage . retrieveString ( KEY_ACCESS_TOKEN ) ; final String refreshToken = storage . retrieveString ( KEY_REFRESH_TOKEN ) ; String idToken = storage . retrieveString ( KEY_ID_TOKEN ) ; String tokenType = storage . retrieveString ( KEY_TOKEN_TYPE ) ; Long expiresAt = storage . retrieveLong ( KEY_EXPIRES_AT ) ; String scope = storage . retrieveString ( KEY_SCOPE ) ; if ( isEmpty ( accessToken ) && isEmpty ( idToken ) || expiresAt == null ) { callback . onFailure ( new CredentialsManagerException ( "No Credentials were previously set." ) ) ; return ; } if ( expiresAt > getCurrentTimeInMillis ( ) ) { callback . onSuccess ( recreateCredentials ( idToken , accessToken , tokenType , refreshToken , new Date ( expiresAt ) , scope ) ) ; return ; } if ( refreshToken == null ) { callback . onFailure ( new CredentialsManagerException ( "Credentials have expired and no Refresh Token was available to renew them." ) ) ; return ; } authClient . renewAuth ( refreshToken ) . start ( new AuthenticationCallback < Credentials > ( ) { @ Override public void onSuccess ( Credentials fresh ) { Credentials credentials = new Credentials ( fresh . getIdToken ( ) , fresh . getAccessToken ( ) , fresh . getType ( ) , refreshToken , fresh . getExpiresAt ( ) , fresh . getScope ( ) ) ; saveCredentials ( credentials ) ; callback . onSuccess ( credentials ) ; } @ Override public void onFailure ( AuthenticationException error ) { callback . onFailure ( new CredentialsManagerException ( "An error occurred while trying to use the Refresh Token to renew the Credentials." , error ) ) ; } } ) ; }
Retrieves the credentials from the storage and refresh them if they have already expired.
It will fail with {@link CredentialsManagerException} if the saved access_token or id_token is null,
or if the tokens have already expired and the refresh_token is null.

@param callback the callback that will receive a valid {@link Credentials} or the {@link CredentialsManagerException}.