如何解决请求中的重定向URI http:// localhost:8080 /与为OAuth客户端授权的重定向URI不匹配
我正在尝试组织对Google Ads API的访问。
即,获取刷新令牌。
我这样做:
$ ./authenticate_in_web_application.py --client_secrets_path=/path/to/secrets.json
secrets.json
{
"web": {
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs","auth_uri": "https://accounts.google.com/o/oauth2/auth","client_id": "some_client_id","client_secret": "i_m_so_secret","javascript_origins": [
"https://avtomotokniga.ru"
],"project_id": "smpt-auth","redirect_uris": [
"https://avtomotokniga.ru/"
],"token_uri": "https://oauth2.googleapis.com/token"
}
}
脚本运行时,它为我提供了超链接。我点击链接并找到了它:
Error 400: redirect_uri_mismatch
The redirect URI in the request,http://localhost:8080/,does not match the ones authorized for the OAuth client. To update the authorized redirect URIs,visit: https://console.developers.google.com/apis/credentials/oauthclient/secret-uvml458ip15qmarbruq83bkmfbu3vilf.apps.googleusercontent.com?project=secret
问题
localhost:8080 来自何处?
我仔细检查了secrets.json和凭据页面(https://console.developers.google.com/apis/credentials)。
肯定有重定向URI:
它已保存。我多次打开和关闭页面。然后下载了json文件,即绝对考虑了重定向URI。
如何定位问题?
解决方法
按您的屏幕截图显示,它不存在。 在您的控制台上,我在重定向列表中仅看到https://avtomotokniga.ru/。
您需要单击底部的“添加URI”按钮,并在其中也添加localhost:8080。
,如果您未明确指定returnURL
,则Google将默认值指定为“ / google-signin”。
在.NET startup.auth.cs
文件中,将URL添加为
//google OAuth 2.0 Client IDs
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
ClientId = "456545-r6k8kf3gffghpoh13212s1fnkkfe.apps.googleusercontent.com",ClientSecret = "VWuu45654655IeNUDEw32",CallbackPath = new PathString("/CONTROLLER/ExternalLoginCallbackFUNCTION")
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。