Background:
I know that this question has been asked before, I have gone through all answers I have found, but it seems that no one have given a satisfying answer to it yet. I have seen that Facebook had a bug open about this but closed it due to lack of info. Thats why I ask again to see if someone out there now have found any good solution.
I'm trying to get a short-lived access token to be able to get a users profile. This worked fine up until some time ago and now I only get "OAuthException: This authorization code has been used." back from the api call.
Technologies used:
- PHP (no third part libraries or Facebook SDKs for Facebook API interaction)
- cURL
- Graph API
- https
Logical Flow
Get the url for the login dialogue looking similar to this:
https://graph.facebook.com/oauth/authorize?client_id=[APP_ID]&redirect_uri=[URLENCODED_REDIRECT_URI]&display=popup&scope=publish_stream
Login through the Facebook login dialogue. On success redirect the user to the specified callback URI and add the "code" quersy-string variable.
When the user is redirected to the specified callback URI it immediately try to get get a short-lived accesstoken with the "code" variable provided by the Facebook login dialogue. I do that by calling this url:
https://graph.facebook.com/oauth/access_token?client_id=[APP_ID]&redirect_uri=[URLENCODED_REDIRECT_URI]&client_secret=[APP_SECRET]&code=[CODE_SENT_FROM_FACEBOOK]
I receive the following response EVERY TIME: {"error":{"message":"This authorization code has expired.","type":"OAuthException","code":100}}
I already know that:
- I shall get a short-lived access token
- the code is only valid for 10 minutes
- I can only use the code once (my logging confirm that I only call the access_token request just once)
What have I missed? Why has it suddenly stopped working? Any answer, tip or trick is very appreciated! Thanks in advance.