Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Graph returned an error: This authorization code has been used. #1254

Open
hminvozone opened this issue Sep 14, 2021 · 1 comment
Open

Graph returned an error: This authorization code has been used. #1254

hminvozone opened this issue Sep 14, 2021 · 1 comment

Comments

@hminvozone
Copy link

I am using the SDK 5.7 version, customer redirected to the facebook login page and redirected back successfully however see This authorization code has been used. error on redirected page.

I have checked this page https://developers.facebook.com/tools/accesstoken/ and I can see the access token

Can any one help?

$fb = new Facebook\Facebook([
   'app_id' => 'xxxxx',
   'app_secret' => 'xxxxxx',
   'default_graph_version' => 'v2.10',
  ]);
    
$helper = $fb->getRedirectLoginHelper($redirectUrl);
if (isset($_GET['state'])) {
    $helper->getPersistentDataHandler()->set('state', $_GET['state']);
}
 
$permissions = ['email']; // optional
if (isset($_GET['code'])) {
  try {
            $accessToken = $helper->getAccessToken();
        } catch (FacebookRequestException $e) {
            echo 'Request error: ' . $e->getMessage();
            exit;
        } catch(Facebook\Exceptions\FacebookResponseException $e) {
            // When Graph returns an error
            echo 'Graph returned an error: ' . $e->getMessage();
            exit;
        } catch(Facebook\Exceptions\FacebookSDKException $e) {
            // When validation fails or other local issues
            echo 'Facebook SDK returned an error: ' . $e->getMessage();
            exit;
        }  catch (Exception $e) {
            echo 'Generic error: ' . $e->getMessage();
            exit;
        }
} else {
  redirectUrl($helper->getLoginUrl($redirectUrl, $permissions));
}
@hminvozone
Copy link
Author

@sergeychernyshev @zpao @killian @klausbreyer guys can you help me out?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant