google api “Permission denied to generate login hint for target domain”
在https://console.developers.google.com/apis/credentials/oauthclient中,我创建了" Web应用程序的客户端ID",没有限制:空的" Authorized JavaScript origins"和空的" Authorized redirect URIs"。 我收到一个客户ID,并将其放在页面上。
以下是最基本的页面示例。 我收到消息:
400.这是一个错误。
错误:invalid_request
拒绝权限以生成目标域的登录提示。
??? 怎么了?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <head> <meta name="google-signin-client_id" content="****26190863-tm7mr9racl8bgooifq2kjssb1n7teoob.apps.googleusercontent.com"> </head> <script src="https://apis.google.com/js/platform.js" async defer> <script type="text/javascript"> function onSignIn(googleUser) { var profile = googleUser.getBasicProfile(); console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead. console.log('Name: ' + profile.getName()); console.log('Image URL: ' + profile.getImageUrl()); console.log('Email: ' + profile.getEmail()); } <body> </body> |
作为我的评论的后续内容,如果您查看官方文档,则
文档是这样的,(单击此处查看文档)
1.在"授权的JavaScript来源"字段中,输入应用程序的来源。 您可以输入多个来源,以允许您的应用在不同的协议,域或子域上运行。 您不能使用通配符。 在下面的示例中,第二个URL可以是生产URL。
http://本地主机:4567
https://myproductionurl.example.com
2.授权重定向URI字段不需要值。 重定向URI不能与JavaScript API一起使用。
希望这可以帮助!。
empty"Authorized JavaScript origins" and empty"Authorized redirect URIs"
我非常确定您需要在开发(本地主机)和生产中都填写有效信息。 如果同时使用http和https,则也需要使用这两个版本。