我正在使用 google_sign_in flutter 插件将 Google Sign In Auth 与我的应用程序集成。除了 idToken 在一小时后过期外,它一切正常。就在它到期之前,我正在调用 signInSilently 来刷新令牌。它适用于 iOS,但对于 Android,它返回相同的旧令牌。我查看了插件的代码,根据对代码的评论,它看起来像是设计使然,它不会刷新 Android 的令牌。
Future<GoogleSignInAuthentication> get authentication async {
if (_googleSignIn.currentUser != this) {
throw StateError('User is no longer signed in.');
}
final GoogleSignInTokenData response =
await GoogleSignInPlatform.instance.getTokens(
email: email,
shouldRecoverAuth: true,
);
// On Android, there isn't an API for refreshing the idToken, so re-use
// the one we obtained on login.
if (response.idToken == null) {
response.idToken = _idToken;
}
return GoogleSignInAuthentication._(response);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果是这种情况,我该如何刷新令牌(尤其是对于 android)。在插件回购,我还发现了其他开发者抱怨同样的问题,但没有任何反应 …