在https://code.google.com/apis/console网站上,我已经注册了我的应用程序,设置生成的客户端ID:和客户端秘密到我的应用程序,并尝试登录谷歌。 不幸的是,我收到了错误信息:

Error: redirect_uri_mismatch
The redirect URI in the request: http://127.0.0.1:3000/auth/google_oauth2/callback did not match a registered redirect URI

scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
response_type=code
redirect_uri=http://127.0.0.1:3000/auth/google_oauth2/callback
access_type=offline
approval_prompt=force
client_id=generated_id

这条信息是什么意思,我该如何修复它? 我使用宝石omniauth-google-oauth2。


当前回答

如果你使用谷歌+ javascript按钮,那么你必须使用postmessage而不是实际的URI。我花了几乎一整天的时间才弄清楚,因为谷歌的文档出于某种原因没有清楚地说明它。

其他回答

确保检查协议“http://”或“https://”,因为谷歌也检查协议。 最好将两个URL都添加到列表中。

检查表:

HTTP还是https? &或&? 后面的斜杠(/)还是打开? (CMD/CTRL)+F,在证书页面中搜索精确匹配。如果 没有找到,那就去找失踪的那个。 等待谷歌刷新它。可能每半小时发生一次,如果你 经常更换,否则可能会留在池中。就我的情况而言,几乎用了半个小时才生效。

这个问题的主要原因只会来自chrome和chrome处理WWW和非WWW不同取决于你如何在浏览器中输入你的URL,它从谷歌搜索并直接显示结果,所以发送的重定向URL在不同的情况下是不同的

添加所有可能的组合,你可以找到确切的url从fiddler, 400错误弹出不会给你确切的http和www信息

The trick is to input the right redirect url at the point of creating the ID. I found that updating the redirect url once the ID has been created via an 'Edit' just doesn't get the job done. What also worked for me is duplicating the entire 'vendor' folder and copying it to the same location where the 'oauth' file is (just until you successfully generate the token and then you can delete the duplicate 'vendor' folder). This is because trying to point to the vendor folder via '../vendor/autoload' didn't work for me.

因此,删除您现有的麻烦客户端OAuth ID,并尝试这种方法,它将工作。

我需要在api和服务下创建一个新的客户端ID ->凭据->创建凭据-> OAuth ->其他

然后下载并使用client_secret。Json和我的命令行程序上传到我的YouTube帐户。我试图使用Web应用程序OAuth客户端ID,这给了我浏览器中的重定向URI错误。