Cannot access application using the specified access_token
Asked Answered
O

4

7

I am using Facebook long time tokens(2 months), but FB starts to be nondeterminic and gives me sometimes this return

{
   "error": {
      "message": "Cannot access application using the specified access_token",
      "type": "OAuthException",
      "code": 1
   }
}

I am using PHP SDK.

I am using this link to get 2 months token https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRETgrant_type=fb_exchange_token&fb_exchange_token=SHORT_TIME_TOKEN

Any ideas?

Och answered 22/8, 2012 at 19:43 Comment(4)
Are you sure you're not confusing apps, and passing an access token for app A with the client_id and client_secret from app B?Bedpan
Yes I am sure, but this problem starts when the app was used by many people. Is it possible that the problem was caused by FB API? I had so many querys in short time.Och
developers.facebook.com/tools/debug <-- have you tried debugging the access token you get back?Genseric
If the user with the buggy token refreshes the page, does it work?Five
M
2

I was experiencing this issue, and got some support direct from FB staff. The most likely cause of this error is "demographic checks" for the user.

Our app had an age-gate as it was alcohol related. Certain users' profiles did not contain enough information for FB to ensure they were above the drinking age for their location, so the session creation failed. Why this only happened on this call and not on earlier ones, I don't know.

Does your app have an age-gate, or anything similar?

Matlick answered 7/12, 2013 at 5:36 Comment(1)
I was experiencing this issue too, our app had country restricted.Malpighi
K
0

Your query is missing an & after APP_SECRET, before grant_type. It should read:

https://graph.facebook.com/oauth/access_token?
client_id=APP_ID&
client_secret=APP_SECRET&  
grant_type=fb_exchange_token&           
fb_exchange_token=SHORT_LIVED_ACCESS_TOKEN 

Source: Extending Access Tokens on Facebook Developers.

Edit:
If the OP means that out of the current app user base, some users experienced expired sessions and reported the issue, the wrong query string is a possible explanation.

The error would result in the access_token not being extended, but log-in will be still be granted with the shorter-lived access token. In this case the faulty query string was in the code base all along, but was only discovered when live users' access_tokens expired earlier than expected, coinciding with "the app [..] used by many people".

If the OP means that using the correct query (and not the one stated in the question) out of many calls from the same client a subset returns with error, then my explanation isn't valid.

Kentigerma answered 12/11, 2012 at 9:10 Comment(0)
U
0

You have the missing & between APP_SECRET and grant_type.

Also, there seem to be a Fb bug on this issue - http://developers.facebook.com/bugs/536272816386515?browse=search_50a37bb1c333b4253892226

Be sure that you extend the tokens immediately after you get the "SHORT_TIME_TOKEN". You can extend user tokens only ( not page tokens ). Be sure that you get a correct "Short time token" before you extend it.

Also, check for "sandbox mode " in your app. It may cause problems when extending tokens. Try switching it to "false".

Hope that helps.

Unrequited answered 14/11, 2012 at 11:17 Comment(0)
F
0

It sounds as if some of your users are erroneously being issued tokens that have a short lifespan instead of the extended ones you ask for.

It is possible you have stumbled upon a known bug with the extended access tokens. Check this bug report on facebook for more information about it as well as this question, although to my knowledge there's no real workaround.

Five answered 14/11, 2012 at 20:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.