【问题标题】:Google+ OAuth on Rails = redirect_uri_mismatchRails 上的 Google+ OAuth = redirect_uri_mismatch
【发布时间】:2015-12-22 09:08:08
【问题描述】:

我使用 rails 4.2.5,尝试了 omniauth-gplusomniauth-google-oauth2 最新版本的 gem 并遇到了同样的问题

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 与其他提供商合作良好)

我已经在device.rb 中添加了require "omniauth-google-oauth2",就像在Google OAuth 2 redirect_uri_mismatch - OmniAuth Rails app 中一样

实际上我正在尝试使用相同的设置。

我认为失败在于我的 console.developers.google.com 设置。 现在我不知道要尝试授权 JavaScript 来源和授权重定向 URI 的其他组合。 (我在 localhost、localhost 别名(带和不带端口)或 heroku 上尝试使用和不使用最后一个'/')

你能说一下,http://localhost:3000 的 google+ api 的哪些设置是完全正确的?

或者我错过了什么?谢谢。

【问题讨论】:

    标签: ruby-on-rails ruby oauth


    【解决方案1】:

    建议你试试

    http://127.0.0.1:3000
    

    就我个人而言,当我使用 oauth 重定向时,我喜欢使用 Thin

    $ gem install 'thin'
    
    $ thin start --ssl
    

    然后我将重定向 uri 设置为

    https://127.0.0.1:3000
    

    这样,不会出现协议不匹配的情况,并且可以让您在请求之间保持会话处于活动状态

    【讨论】:

    • 谢谢。 gem wast good. Thin helps 找到它 mail.ru 帐户的正确 gem 是 omniauth-mail_ru
    猜你喜欢
    • 2014-04-26
    • 2016-01-26
    • 2021-07-20
    • 1970-01-01
    • 2014-02-09
    • 2015-04-03
    • 1970-01-01
    • 2020-11-08
    • 2019-07-14
    相关资源
    最近更新 更多