oauth2.0 OpenId App Auth Android -将刷新的访问令牌发送到vuejs

zy1mlcev  于 2024-01-06  发布在  Android
关注(0)|答案(1)|浏览(187)

你好,我想知道打电话后怎么样。

  1. public String performTokenRefresh() {
  2. final AuthState state = AuthUtils.readAuthState(context, key);
  3. final AuthorizationService service = new AuthorizationService(context);
  4. state.performActionWithFreshTokens(service, new AuthState.AuthStateAction() {
  5. @Override
  6. public void execute(@Nullable String accessToken, @Nullable String idToken,
  7. @Nullable AuthorizationException ex) {
  8. // TODO
  9. }
  10. });
  11. return state.getAccessToken();
  12. }

字符串
看起来当return语句发生的时候,状态还没有更新到包含代码过期时的新tokenResponse,执行中的accessToken是最新的,唯一的问题是我不能从那里返回。
谁能帮帮我。
问候

a0zr77ik

a0zr77ik1#

可能不是最好的方法但我必须要做的是

  1. public String performTokenRefresh() {
  2. AuthState state = AuthUtils.readAuthState(context, key);
  3. AuthorizationService service = new AuthorizationService(context);
  4. state.performActionWithFreshTokens(service, new
  5. AuthState.AuthStateAction() {
  6. @Override
  7. public void execute(@Nullable String accessToken, @Nullable String
  8. idToken, @Nullable AuthorizationException ex) {
  9. updateAuthState(accessToken); // updates the authstate in Shared Preferences
  10. }
  11. });
  12. Thread.sleep(10000); // 10 seconds to work with slow connections
  13. return AuthUtils.readAuthState(context, key).getAccessToken();
  14. }

字符串

展开查看全部

相关问题