rails_api_auth icon indicating copy to clipboard operation
rails_api_auth copied to clipboard

TOKEN_URL's order of appearance for params seems to matter

Open maml opened this issue 9 years ago • 2 comments

I came across an odd issue today when I was implementing facebook authentication in development against a test app I had set up and I'm wondering if anyone else has seen it.

TOKEN_URL in facebook_authentication.rb sets the redirect_uri at the end of the string. Mine had been set and I verified that it matched what I had used for the

  • Oauth dialog request
  • my app's settings on Facebook under Settings -> Basic -> Website -> Site URL
  • and also the Valid OAuth redirect URIs under Client Settings

but I kept seeing

facebook API request failed with status 400.
facebook API error response was:
{"error":{"message":"Missing redirect_uri parameter.","type":"OAuthException","code":191,"fbtrace_id":"FUCYqE8QrwS"}}

I noticed in the FB documentation for Manually Building a Login Flow under Exchanging code for an access token that the parameters are documented in a different order than in facebook_authentication.rb's TOKEN_URL, namely, redirect_uri appears between client_id and _client_secret instead of at the end after code.

I updated my local gem's version of TOKEN_URL to match the order of the params in the documentation and it started working. I wouldn't suspect this would matter but in my case it did.

maml avatar May 31 '16 22:05 maml

I'm having this same issue. Would you mind sharing the location of the file you edited? I can't seem to find it. Thanks!

alfredoreduarte avatar Jul 26 '16 23:07 alfredoreduarte

@alfredoreduarte take a look at rails_api_auth/app/services/facebook_authenticator.rb

maml avatar Jul 27 '16 14:07 maml