-
Notifications
You must be signed in to change notification settings - Fork 28
OAuthException - Code was invalid or expired. #31
Comments
Upon closer inspection, I noticed the following in /samples/website/index.cfm:
if I put userAccessToken = facebookApp.getUserAccessToken(); inside the try condition, then it seems to resolve the error... like so
This might not be the best solution, but it seems to work. |
Indeed, the user access token call should be inside the try/catch. |
I have the same issue. We are building a site for a customer where we are displaying their FB albums, events and status updates on the site. So the user is always the same, there is no FB user login. But the access token for our user keeps expiring. So looking at the code it says: // See if there is a user from a cookie or session So my user is not from a cookie or session, its a persistent user so how can I request the access token for our user - we know the username and password but I just don't know how to request a new access token when it expires. Right now we have to manually log into FB and request a new access token by hand but that won't work for a production site. |
By default, access token expires after 2 hours. You can also manually get an extended token, valid during 60 days : var result = facebookApp.exchangeAccessToken(currentToken); // Current token must be valid
writeDump(result); // Struct with 'access_token' and 'expiration_time' You might store this token in DB with the new expiration time and check it each time user log in. |
Implementing @CFPro suggestion of putting userAccessToken = facebookApp.getUserAccessToken(); inside the try condition, resolved my error with the default set-up. If I just installed the default example after 10 minutes of inactivity I would get the Oath 100 error ... but this seems to solve it. |
My token keeps expiring, and I get "OAuthException - Code was invalid or expired."
I found out their are 4 scenarios which cause this condition:
http://developers.facebook.com/blog/post/500/
How can I error check and reacquire a valid token?
TIA
The text was updated successfully, but these errors were encountered: