小编Cél*_*hez的帖子

Google OAuth 2.0和Devise - "错误":"redirect_uri_mismatch"

我配置Devise使用omn​​iauthFacebookGoogle.它工作正常,Facebook但我遇到了问题Google.

我一次又一次地得到这个错误:

错误 - omniauth:(google_oauth2)身份验证失败!invalid_credentials:OAuth2 :: Error,redirect_uri_mismatch:

{"error":"redirect_uri_mismatch"}

[localhost] [127.0.0.1] [6a9377fe-d0b3-42] RuntimeError - 找不到路径"/ users/auth/google_oauth2/callback"的有效映射:

设计(3.5.2)lib/devise/mapping.rb:49:在`find_by_path!'中

我在Google控制台中尝试了几个URI 但是任何人似乎都没有工作:

Google控制台

的Gemfile

# Social Networks Authentification
gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2'
Run Code Online (Sandbox Code Playgroud)

devise.rb

config.omniauth :facebook, ENV['OAUTH_FACEBOOK_ID'], ENV['OAUTH_FACEBOOK_SECRET'],
                       scope: 'public_profile', image_size: {height: 1600}, info_fields: 'name, id, first_name, last_name, gender, hometown, cover, email, link' # list of permissions

# Not working, "error" : "redirect_uri_mismatch"
config.omniauth :google_oauth2, ENV['OAUTH_GOOGLE_ID'], ENV['OAUTH_GOOGLE_SECRET']
Run Code Online (Sandbox Code Playgroud)

omn​​iauth_callbacks_controller.rb

def self.provides_callback_for(provider) …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails devise omniauth

2
推荐指数
1
解决办法
1395
查看次数

标签 统计

devise ×1

omniauth ×1

ruby-on-rails ×1