Is Omniauth using invalid uri's for facebook authorization?
I'm following along with the Railscast for Simple OmniAuth (in text format here: http://asciicasts.com/episodes/241-simple-omniauth). Everything works perfectly until I add the Facebook login. When trying the "Login With Facebook" link I get the following error.
Invalid redirect_uri: Given URL is not allowed by the 开发者_如何转开发Application configuration.
The URL of my page with the login link is 'http://mluton.example.com:3000/characters/'. In my Facebook app's website settings I have the Site URL set to 'http://mluton.myfitv.com:3000/auth/facebook/callback/'. The trailing slash is required. This is what omniauth will set as the callback when making its authentication request. However, if I look at the URL on the page with the above error I see this at the end.
redirect_uri=http%3A%2F%2Fmluton.example.com%3A3000%2Fauth%2Ffacebook%2Fcallback
No trailing slash. Is there a disconnect between omniauth and Facebook or am I missing something? Is there a way to override the default callback url omniauth generates?
This took some trial and error to get working myself. Try a question mark at the end of the callback URL. This worked for me in the developer console: http://:3000/users/auth/facebook/callback?
You don't need the path component of the URL. Try setting your Site URL to http://mluton.myfitv.com:3000/
in your app's settings. You can also set the Site Domain to mluton.myfitv.com
.
You may find facebook's documentation on server-side authentication useful, although it's a bit short on details regarding exactly how the validation based on redirect_uri
works.
精彩评论