OmniAuth + Devise - Facebook提供商 - OAuthException 191 [英] OmniAuth + Devise - Facebook provider - OAuthException 191

查看:138
本文介绍了OmniAuth + Devise - Facebook提供商 - OAuthException 191的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题



我收到以下错误:

 error:{
message:无效的redirect_uri:应用程序配置不允许给定URL,
type:OAuthException,
code 191
}

这是非常知名的,我发现了许多不同的解决方案来处理和不幸任何人都为我工作。



我试图让它在本地运行在 localhost:3000 但是不能使它工作。



我的配置是一个常见的配置:



config /初始化器/ devise.rb

  config.omniauth:facebook,'396783260390829','a504939e60c3410ed1becc44f41d4b94',{client_options: {ssl:{ca_file:Rails.root.join('lib / assets / cacert.pem')。to_s}}} 

Facebook配置:





Routes.rb

  devise_for:users,:controllers => {:omniauth_callbacks => users / omniauth_callbacks} 

devise_scope:user do
get'/ users / auth /:provider'=> 'users / omniauth_callbacks#passthru'
end

我已经尝试过以下方法: p>

方法1:

  OmniAuth.config .full_host ='`http:// localhost:3000 /`'

这一个是最接近的得到了,因为它重定向回来,但地址是 http:// localhost:3000 // users / auth / facebook / callbacks?xxx



我已经尝试过没有最后一个斜杠 OmniAuth.config.full_host ='http:// localhost:3000',但是我得到了191 。



方法2



正常的初始化程序,没有黑客。 >

方法3



在Facebook配置页面中设置域名。



方法4



应用程序域设置为localhost



方法5



在Fac中设置网站电子书配置为 http:// localhost:3000 / users / auth / facebook



方法6



尝试使用我的ip地址而不是本地主机,并得到相同的错误,但不能在 OmniauthCallbacksController ,但在 graph.facebook.com/oauth/authorize?

  redirect_uri = http:// localhost:3000 / users / auth / facebook / callback 

所有方法的结果



除了我在线解释的所有情况,我得到了


OAuthException 191


在OmniauthCallbackController的故障方法我创建处理回调。



如果您知道其他替代方案或想要查看任何其他方法来帮助我,请随时询问或回答。





解决方案

解决方案



正如@Ashitaka所提到的那样,我必须删除我旧的和不推荐的 omniauth.rb ,所以我的最终和工作配置如下: p>

config / initializers / devise.rb



为了使身份验证工作,我复制cacert到我的资产,并在 devise.rb

 配置中引用.omniauth:facebook,'xxxxxxxxxxxxxxx','a504xxxe60cxxxxed1bexxxxf41d4b94',{client_options:{ssl:{ca_file:Rails.root.join('lib / assets / cacert.pem')。to_s}}} 

Facebook配置:



!图像描述这里] [1]



链接到Facebook auth

  / users / auth / facebook 

谢谢你的帮助,这个问题花了我5个小时来解决。


Problem

I'm getting the following error:

"error": {
      "message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
      "type": "OAuthException",
      "code": 191
   }

It is very known and I found many different solutions to adress it and unfortunatelly any of them worked for me.

I'm trying to make it run locally in the localhost:3000, but can't make it work.

My configuration is a common configuration:

config/initializers/devise.rb

config.omniauth :facebook, '396783260390829', 'a504939e60c3410ed1becc44f41d4b94', {client_options: {ssl: {ca_file: Rails.root.join('lib/assets/cacert.pem').to_s}}}

Facebook config:

Routes.rb

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }

devise_scope :user do
  get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
end

I already tried the following approaches:

Approach 1:

OmniAuth.config.full_host = '`http://localhost:3000/`'

This one was the closest I got, because it redirect me back, but the adress was http://localhost:3000//users/auth/facebook/callbacks?xxx

I already tried without the last slash OmniAuth.config.full_host = 'http://localhost:3000', but then I got the 191.

Approach 2

Normal initializer, without the hack.

Approach 3

Set the domain in the Facebook configuration page.

Approach 4

Set App Domains to localhost

Approach 5

Set the Web Site in Facebook configuration to http://localhost:3000/users/auth/facebook

Approach 6

Tryied with my ip adress instead of localhost and got the same error, but pnot in the failure of OmniauthCallbacksController, but in the graph.facebook.com/oauth/authorize?

redirect_uri=http://localhost:3000/users/auth/facebook/callback

Result for all approaches

In all the cases except the ones I explained inline I got

OAuthException 191

in the failure method of OmniauthCallbackController I created to handle the callback.

Please if you know other alternatives or want to see anything else to try to help me, feel free to ask or answer.


解决方案

Solution

As mentioned by @AshitakaI had to remove my old and deprecated omniauth.rb, so my final and working configuration is the following one:

config/initializers/devise.rb

In order to make authentication works I copied the cacert to my assets and referenced in the devise.rb

config.omniauth :facebook, 'xxxxxxxxxxxxxxx', 'a504xxxe60cxxxxed1bexxxxf41d4b94', {client_options: {ssl: {ca_file: Rails.root.join('lib/assets/cacert.pem').to_s}}}

Facebook config:

![enter image description here][1]

Link to Facebook auth

/users/auth/facebook

Thank you for the help, this issue took me 5 hours to solve.

这篇关于OmniAuth + Devise - Facebook提供商 - OAuthException 191的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆