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

Unknown path components: /oauth/access_token #1119

Open
dejan7 opened this issue Apr 22, 2019 · 1 comment
Open

Unknown path components: /oauth/access_token #1119

dejan7 opened this issue Apr 22, 2019 · 1 comment

Comments

@dejan7
Copy link

dejan7 commented Apr 22, 2019

    $fb = new \Facebook\Facebook([
        'app_id' => env('FB_APP_ID'),
        'app_secret' => env('FB_APP_SECRET'),
        'default_graph_version' => env('FB_API_VERSION')
    ]);

    $oauth = $fb->getOAuth2Client();
    $longLivedToken = $oauth->getLongLivedAccessToken($shortLivedToken);

    return $longLivedToken->getValue();

Results in:

[2019-04-22 12:47:38] local.ERROR: Unknown path components: /oauth/access_token {"userId":1,"exception":"[object] (Facebook\\Exceptions\\FacebookResponseException(code: 2500): Unknown path components: /oauth/access_token at /home/vagrant/projects/insta/vendor/facebook/graph-sdk/src/Facebook/Exceptions/FacebookResponseException.php:142, Facebook\\Exceptions\\FacebookAuthenticationException(code: 2500): Unknown path components: /oauth/access_token at /home/vagrant/projects/insta/vendor/facebook/graph-sdk/src/Facebook/Exceptions/FacebookResponseException.php:142)
[stacktrace]
#0 /home/vagrant/projects/insta/vendor/facebook/graph-sdk/src/Facebook/FacebookResponse.php(210): Facebook\\Exceptions\\FacebookResponseException::create(Object(Facebook\\FacebookResponse))
#1 /home/vagrant/projects/insta/vendor/facebook/graph-sdk/src/Facebook/FacebookResponse.php(255): Facebook\\FacebookResponse->makeException()
#2 /home/vagrant/projects/insta/vendor/facebook/graph-sdk/src/Facebook/FacebookResponse.php(82): Facebook\\FacebookResponse->decodeBody()
#3 /home/vagrant/projects/insta/vendor/facebook/graph-sdk/src/Facebook/FacebookClient.php(224): Facebook\\FacebookResponse->__construct(Object(Facebook\\FacebookRequest), '{\"error\":{\"mess...', 400, Array)
#4 /home/vagrant/projects/insta/vendor/facebook/graph-sdk/src/Facebook/Authentication/OAuth2Client.php(277): Facebook\\FacebookClient->sendRequest(Object(Facebook\\FacebookRequest))
#5 /home/vagrant/projects/insta/vendor/facebook/graph-sdk/src/Facebook/Authentication/OAuth2Client.php(226): Facebook\\Authentication\\OAuth2Client->sendRequestWithClientParams('/oauth/access_t...', Array)
#6 /home/vagrant/projects/insta/vendor/facebook/graph-sdk/src/Facebook/Authentication/OAuth2Client.php(186): Facebook\\Authentication\\OAuth2Client->requestAnAccessToken(Array)
#7 /home/vagrant/projects/insta/app/Support/FBTokenExchanger.php(21): Facebook\\Authentication\\OAuth2Client->getLongLivedAccessToken('......')
#8 /home/vagrant/projects/insta/app/Http/Controllers/ProfileConnectController.php(21): App\\Support\\FBTokenExchanger->longLivedFromShortLived('.....')
#9 [internal function]: App\\Http\\Controllers\\ProfileConnectController->connectOwnedProfile(Object(Illuminate\\Http\\Request))

PHP 7.3
facebook/graph-sdk: 5.7.0
Laravel: 5.8.7 (but i don't think this is related to Laravel in any way)

@SuperStar518
Copy link

SuperStar518 commented Feb 21, 2020

I faced same issue and solved it by sending json request manually

      $response = $fb->sendRequest(
        'GET',
        '/oauth/access_token',
        [
          'client_id'     => $config['client_id'],
          'client_secret' => $config['client_secret'],
          'grant_type'    => 'fb_exchange_token',
          'fb_exchange_token' => $short_token
        ],
        $short_token,
        null,
        'v2.7');

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

2 participants