gpt4 book ai didi

android - 重置 GoogleAuthUtil,以便再次获得许可

转载 作者:行者123 更新时间:2023-11-30 02:37:42 25 4
gpt4 key购买 nike

我正在使用 google play 服务身份验证示例 here

如何重置 GoogleAuthUtil 以便它再次请求许可?

它通过抛出提供给对话框的 userRecoverableException 来请求许可。但它只请求一次许可。我需要再次测试请求权限。

我尝试卸载示例应用程序并重新安装示例应用程序,但这没有用它不请求许可似乎它已经知道该应用程序。

protected String fetchToken() throws IOException {
try {
return GoogleAuthUtil.getToken(mActivity, mEmail, mScope);
} catch (UserRecoverableAuthException userRecoverableException) {
// GooglePlayServices.apk is either old, disabled, or not
// present, which is
// recoverable, so we need to show the user some UI through the
// activity.
MyGooglePlay.handleException(userRecoverableException);
} catch (GoogleAuthException fatalException) {
onError("Unrecoverable error " + fatalException.getMessage(),
fatalException);
}
return null;
}


/**
* This method is a hook for background threads and async tasks that need to provide the
* user a response UI when an exception occurs.
*/
public void handleException(final Exception e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (e instanceof GooglePlayServicesAvailabilityException) {
// The Google Play services APK is old, disabled, or not present.
// Show a dialog created by Google Play services that allows
// the user to update the APK
int statusCode = ((GooglePlayServicesAvailabilityException)e)
.getConnectionStatusCode();
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(statusCode,
HelloActivity.this,
REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR);
dialog.show();
} else if (e instanceof UserRecoverableAuthException) {
// Unable to authenticate, such as when the user has not yet granted
// the app access to the account, but the user can fix this.
// Forward the user to an activity in Google Play services.
Intent intent = ((UserRecoverableAuthException)e).getIntent();
startActivityForResult(intent,
REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR);
}
}
});
}

最佳答案

您可以按照以下步骤使用 Google 设置 应用取消对连接的应用程序的授权:

  1. 启动 Google 设置应用

Google Settings App Icon

  1. 选择已连接的应用选项(在顶部)

Google Settings options

  1. 显示连接的应用程序列表;找到您要取消授权的应用程序并选择它。抱歉,没有屏幕截图,因为我无法从它的 ATM 中删除个人信息 - 但在这里做什么应该非常简单:)

  2. 最后,点击应用详情页面的Disconnect按钮(在底部)

Connected app details

请注意,应用程序取消授权可能需要一些时间。

关于android - 重置 GoogleAuthUtil,以便再次获得许可,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26245204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com