Might not be the best way to do it but what I am having to do is
public String performTokenRefresh() {
AuthState state = AuthUtils.readAuthState(context, key);
AuthorizationService service = new AuthorizationService(context);
state.performActionWithFreshTokens(service, new
AuthState.AuthStateAction() {
@Override
public void execute(@Nullable String accessToken, @Nullable String
idToken, @Nullable AuthorizationException ex) {
updateAuthState(accessToken); // updates the authstate in Shared Preferences
}
});
Thread.sleep(10000); // 10 seconds to work with slow connections
return AuthUtils.readAuthState(context, key).getAccessToken();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…