Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dealing with Oauth 2.0-facebook gem error 100: This authorization code has been used

I have been working on setting up facebook authentication for my rails app and while testing, after logging-in with my facebook account, I keep getting this error:

OAuth2::Error:
{"error":{"message":"This authorization code has been used.","type":"OAuthException","code":100}}

I'm not really sure where to begin with this, but can't seem to find anything else online about it. Any guidance would be appreciated, happy to provide more info if it would be useful.

like image 656
Alex Stein Avatar asked Jul 10 '12 05:07

Alex Stein


People also ask

What is oauth exception on Facebook?

OAuthException: If you receive an OAuthException error, it means that Edgar doesn't have the correct permissions to access your Facebook accounts right now. The password may have been changed on Facebook or Facebook may have reset your security session.

How do I use OAuth2 on Facebook?

In the Settings page, you need to add redirect URL in order to tell Facebook where a user will be redirected back after authorization. I have added http://localhost:8000/auth/facebook/callback as the redirect URL. Click on the SaveChanges button. You will see app id and app secret keys.

How does Oauth authorization code work?

The authorization code is a temporary code that the client will exchange for an access token. The code itself is obtained from the authorization server where the user gets a chance to see what the information the client is requesting, and approve or deny the request.


1 Answers

I had this issue as well. I was seeing the "(facebook) Callback phase initiated." message twice in my Rails logs. It turns out that I was initializing FB authentication twice (I am using Devise and Omniauth-Facebook), and I'm guessing one of these was attempting to reset the access token.

Disabling the initializer in Omniauth-Facebook (config/initializers/omniauth.rb) fixed my issue.

like image 89
imgrgry Avatar answered Oct 20 '22 03:10

imgrgry