【发布时间】:2017-06-29 13:54:39
【问题描述】:
我按照这里的示例Google+ API List with C# 我使用此代码对 Google plus API 进行身份验证:
string[] scopes = new string[] {PlusService.Scope.PlusLogin,
PlusService.Scope.UserinfoEmail,
PlusService.Scope.UserinfoProfile
};
// here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData%
UserCredential credential =
GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
{
ClientId = "xxxx-jh7244ds8ruseviasg0a5g6ln09p0l44.apps.googleusercontent.com",
ClientSecret = "e5kjgbVJz8o92Xqb7RvpzqPk"
},
scopes,
Environment.UserName,
CancellationToken.None,
new FileDataStore("Daimto.GooglePlus.Auth.Store")
).Result;
当我运行代码时,我得到以下错误:
即使是在 http://localhost:53308/ 上运行的程序也是我在 Google 开发者控制台中的设置。
【问题讨论】:
-
尝试在您的项目上启用 SSL (Web Project->Properties->SSL Enabled = true),然后将这些 URL 用于您的 google 凭据。
-
出现同样的错误
-
您收到的错误似乎表明您正在重定向到未经控制台授权的 URL。
标签: c# asp.net-mvc-4 google-api google-plus google-api-dotnet-client