Google api &引用;政策“强制执行”;为google plus交换oauth2令牌时出错

Google api &引用;政策“强制执行”;为google plus交换oauth2令牌时出错,google-api,google-oauth,google-api-dotnet-client,Google Api,Google Oauth,Google Api Dotnet Client,我们的应用程序在上周二之前一直运行良好。在为google plus交换oauth2令牌时,我们不断收到“策略强制”错误。谷歌的回应是: Google.Apis.Auth.OAuth2.Responses.TokenResponseException: Error:"policy_enforced", Description:"Access denied by a security policy established by the Google Apps administrator of y

我们的应用程序在上周二之前一直运行良好。在为google plus交换oauth2令牌时,我们不断收到“策略强制”错误。谷歌的回应是:

Google.Apis.Auth.OAuth2.Responses.TokenResponseException: 
Error:"policy_enforced", 
Description:"Access denied by a security policy established by the Google Apps administrator of your organization. Please contact your administrator for further assistance.", 
Uri:""
我们使用的是GoogleAPI dotnet客户端,代码非常简单

var flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
{
    DataStore = new CustomGoogleDataStore(),
    ClientSecrets = new global::Google.Apis.Auth.OAuth2.ClientSecrets { ClientId = client.ID, ClientSecret = client.Secret },
    Scopes = scopes.Split(' '),
});
var token = flow.ExchangeCodeForTokenAsync(guid, code, redirectUri, CancellationToken.None).Result;
范围包括:

"https://www.googleapis.com/auth/plus.login",
"https://www.googleapis.com/auth/plus.profile.emails.read",
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email",
"https://mail.google.com/"
这个问题是随机发生的。Util现在我找不到100%复制它的方法


请告诉我这个问题是什么,我们非常感谢您的建议。

我最近遇到了同样的问题。联系Google团队后,我们发现出现此问题是因为授权范围与登录时的请求不匹配。我们使用了最新的授权范围和while用户登录。但在GAMAPI控制台中,Google硬编码了不推荐的作用域




将最新授权范围还原为不推荐的范围后,登录工作正常。

感谢您的反馈。但有时它很管用。如果它是由范围问题引起的,它会完全关闭。我一直在尝试复制它。您在云控制台中启用了哪些API?以下API已启用:管理SDK、BigQuery API、日历API、Chrome Web Store API、联系人API、驱动器API、谷歌应用程序市场API、谷歌应用程序市场SDK、谷歌云SQL、谷歌云存储、谷歌云存储JSON API、谷歌+API、谷歌+域名API、谷歌+社交网站API、,任务API、Ad Exchange和API如果您使用的是较旧的客户端库,我想知道这是否与此有关。我无法用当前客户端重新创建它LibYou是否遵循错误建议并与管理员联系???在生产上运行数天后,它证明这是正确的答案。谢谢你,巴拉尼!