Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.
This repository was 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

Description

@hminvozone

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));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions