Android Google Play服务-强制显示权限窗口(授予访问权限)

Android Google Play服务-强制显示权限窗口(授予访问权限),android,authentication,permissions,oauth-2.0,google-play-services,Android,Authentication,Permissions,Oauth 2.0,Google Play Services,我在我的应用程序中使用Google Play服务,但最近我发现了一些奇怪的事情,我不知道如何处理它 如果您正在使用Google Play服务,您第一次知道,在生成令牌之前,您需要授予应用程序使用所选API的权限(授予访问权限) 之后,您的应用程序将在此处可见: 我的应用程序就在那里。一切正常。我想从头开始测试它,我撤销了对我的应用程序的访问权,然后。。。它停止工作了。我无法在取消对我的应用程序的访问后强制Google Play服务显示此窗口。我没有谷歌API的权限,但谷歌应该向我显示重新添加

我在我的应用程序中使用Google Play服务,但最近我发现了一些奇怪的事情,我不知道如何处理它

如果您正在使用Google Play服务,您第一次知道,在生成令牌之前,您需要授予应用程序使用所选API的权限(授予访问权限)

之后,您的应用程序将在此处可见:

我的应用程序就在那里。一切正常。我想从头开始测试它,我撤销了对我的应用程序的访问权,然后。。。它停止工作了。我无法在取消对我的应用程序的访问后强制Google Play服务显示此窗口。我没有谷歌API的权限,但谷歌应该向我显示重新添加API的权限窗口

有办法再次显示这个窗口吗


我正在使用GoogleAccountCredential.UsingAuth2函数获取用户令牌和数据(包括UserRecoverableAuthIOException、startActivityForResult(例如getIntent()、请求授权)等所有异常)


据我所知,GoogleAccountCredential使用Google Play服务来管理OAuth2流,您只需要提供用户名。取消访问后,它将不工作。

使用Google Play服务:

添加到您的范围中

例如:

String scope="oauth2:https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"

final String token = GoogleAuthUtil.getToken(context, "xxxx@gmail.com", scope);
或“暴力”


现在,当您在此处撤销访问权限时,应用程序将再次显示设备中的权限窗口。

我正在使用GoogleAccountCredential.UsingAuth2(…)获取令牌。这是您应该如何使用Google Play服务(推荐)完成的。但线索是。它正在工作,但有时您需要等待相当长的时间才能看到此对话框。同时,您将收到令牌错误。
Intent res = new Intent();
res.addCategory("account:xxxx@gmail.com");
res.addCategory("scope:oauth2:https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile");
res.putExtra("service", "oauth2:https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile");
Bundle extra= new Bundle();
extra.putString("androidPackageName","com.your.package");
res.putExtra("callerExtras",extra);
res.putExtra("androidPackageName","com.your.package");
res.putExtra("authAccount","xxxx@gmail.com");

String mPackage = "com.google.android.gms";
String mClass = "com.google.android.gms.auth.TokenActivity";
res.setComponent(new ComponentName(mPackage,mClass));
startActivityForResult(res,100);