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.