Reputation: 371
Now I am trying to set a Facebook Authorization system. But I got an erro message and don't know why. Could you give me some advice??
Error message:
{
"error": {
"message": "Invalid redirect_uri: \u6307\u5b9a\xxxx\u308c\u305fURL\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u3067\u8a31\u53ef\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002",
"type": "OAuthException",
"code": 191
}
}
What I did is as follows;
①Gemfile
gem 'omniauth'
gem 'omniauth-facebook'
②bundle install
③config /config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook,"App ID","App Secret"
end
※Site URL on facebook dev
http://127.0.0.1
④app/views/layout/application.html.erb <%= link_to "Facebook Login", "/auth/facebook" %>
⑤config/routes.rb
#OmniAuth
match "/auth/:provider/callback" => "sessions#callback"
match "/logout" => "sessions#destroy", :as=>:logout
match '/auth/failure', to: redirect('/')
⑥/app/controllers/sessions_controller.rb
class SessionsController < ApplicationController
def callback
raise request.env["omniauth.auth"].to_yaml
end
end
Upvotes: 0
Views: 110
Reputation: 656
You need to change the site URL at the facebook devloper's app setting. I hope that it will help you.
From http://127.0.0.1 to http://localhost
Upvotes: 0
Reputation: 9173
You must have created your apps page on facebook, go there and edit your site url. If you are on local server then use http://localhost:3000
if 3000 is your port number
Upvotes: 0
Reputation: 6015
Give the Site URL on facebook dev as your system IP address like http://192.168.88.9999:3000
and
run the application with IP address
Hope this will help you :)
Upvotes: 1