我使用rails 4.2.5,尝试了omniauth-gplus
和omniauth-google-oauth2
最新版本的宝石并遇到了同样的问题
omniauth.error"=>#<OAuth2::Error: redirect_uri_mismatch:
{ "error" : "redirect_uri_mismatch" }>,
"omniauth.error.type"=>:invalid_credentials,
"omniauth.error.strategy"=>#<OmniAuth::Strategies::GPlus>
在OmniauthCallbacksController
我正在进入:failure
(OAuth
与其他提供商合作良好)
我已在require "omniauth-google-oauth2"
中添加device.rb
,例如Google OAuth 2 redirect_uri_mismatch - OmniAuth Rails app
其实我正在尝试相同的设置。
我认为失败在我的console.developers.google.com设置中。 现在我不知道授权JavaScript起源和授权重定向URI的其他组合。 (我在localhost,localhost别名(有和没有端口)或heroku上使用和不使用last'/'进行了尝试)
你能说我,http://localhost:3000的google + api的设置是完全正确的吗?
或许我错过了什么?谢谢。
答案 0 :(得分:0)
我建议你试试
http://127.0.0.1:3000
就个人而言,当我使用oauth重定向时,我喜欢使用瘦
$ gem install 'thin'
$ thin start --ssl
然后我将重定向uri设置为
https://127.0.0.1:3000
通过这种方式,不存在协议不匹配,并且可以让您在请求之间保持会话活动