Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Access Token is Valid but We get OAuthException: An active access token error

We've been working on an application for about 2 months, and everything was going perfectly. we were using PHP SDK and offline mode in permissions for login But since some days ago after recent changes in Facebook api and removing offline mode we started facing the problem of "Uncaught OAuthException: An active access token must be used to query information about the current user."

The main problem is that it does happen after a while working in our app (about 10 mins) but at the same time when we check the validity of the token via this link we see that the token is still valid on the other hand the cookie does still exist and it doesn't expire but we get this error : "Uncaught OAuthException: An active access token must be used to query information about the current user"

I've already visited this link and I downloaded the latest version but it didn't help could anyone help us please where might be making mistake?


Thanks for responses, I think same as yacon it seems there's a bug when accessing facebook->api(/me) at the moment we are handling some parts of the app with javascript which is a real headache to use javascript sdk and PhP sdk alongside with each other

like image 926
Siavosh Avatar asked Dec 29 '25 17:12

Siavosh


1 Answers

You can solve this simply store accesstoken to session variable after getLoginUrl

$facebook->getLoginUrl(...)

then whenever you initialize facebook

$facebook = new Facebook(array(
  'appId' => Yii::app()->params['facebook_appId'],
  'secret' => Yii::app()->params['facebook_appSecret'],
));

get the accesstoken from session and set it using setAccessToken

$facebook->setAccessToken(Yii::app()->session['access_token']);

like image 178
22francis Avatar answered Jan 01 '26 17:01

22francis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!