我正在尝试从Google帐户登录并使用acct.getIdToken()获取令牌。 我第一次得到一个有效的令牌,但在我尝试重新登录的过期时间后,它给了我无效的令牌。令牌已过期,所以我已经注销以及撤销但仍然提供相同的过期令牌。我是从https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=
验证的请注意,此问题仅在少数移动设备中发生,它看起来像谷歌方面的错误,它适用于大多数用户
登录和获取结果的过程如下:
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
onActivityResult代码
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
Log.e(TAG, " token " + acct.getIdToken());
SignOut并撤消令牌过期时调用的代码
private void signOut() {
if (mGoogleApiClient != null) {
if (mGoogleApiClient.isConnected()) {
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
Log.e(TAG, "SuccesFully Logout ");
}
});
}
Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
// ...
}
});
}
}