【发布时间】:2019-05-09 21:22:06
【问题描述】:
我有以下客户端密码
{
"web": {
"client_id": "testid",
"project_id": "testproj",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://www.googleapis.com/oauth2/v3/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "test-sec",
"redirect_uris": [
"https://localhost:8080/oauth2callback"
]
}
}
我得到了
“错误:redirect_uri_mismatch 请求中的重定向 URI http://127.0.0.1:8414/authorize/ 与授权给 OAuth 客户端的不匹配。
要更新授权的重定向 URI,请访问:“。请您提出建议,如何解决它。
我正在使用 C#。我已经用这个创建了凭据 -
GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, scopes,
"user",
CancellationToken.None,
new FileDataStore(Directory.GetCurrentDirectory() + "\\AccessToken\\" ,
true)).Result;
但第一次,它会弹出登录名,一旦我登录,它就会在文件夹中创建Google.Apis.Auth.OAuth2.Responses.TokenResponse-user 文件。有没有办法绕过第一次登录?
谢谢。
【问题讨论】:
-
您发布的有效负载或响应是 JSON,您从哪里得到错误?如果错误来自服务器响应,请发布完整的响应。也只是从消息中我怀疑你必须将你的 redirect_uris 更改为你授权为 OAuth 回调的那些,所以你需要将
https://localhost:8080/oauth2callback更改为http://127.0.0.1:8414/authorize/。
标签: google-api youtube-api google-oauth youtube-data-api