davidtsadler / ebay-sdk-examples

Several examples of using the eBay SDK for PHP
http://devbay.net
Apache License 2.0
184 stars 100 forks source link

02-get-user-token.php | Authorization code #60

Closed klachhab closed 4 years ago

klachhab commented 6 years ago

When i execute the file the browser displays this error message : Status Code: 400 invalid_grant: the provided authorization grant code is invalid or was issued to another client

How can i find the grant code ?

Please help

congloi commented 6 years ago

same issue with me :(

Tekrajs commented 6 years ago

I am also stuck here. After I go to 01-get-app-token.php I get an app token, And the I hit 02-get-user-token.php then it say this ->

               [error] => invalid_request
               [error_description] => request is missing a required parameter or malformed.

               *** I tried this small edit ***
                $service = new Services\OAuthService([
            'credentials' => $config['production']['credentials'],
            'ruName' => $config['production']['ruName'],
            'sandbox' => false,
        ]);
        $token = $config['production']['testtoken'];

        /**
         * Create the request object.
         */
        $request = new Types\GetUserTokenRestRequest();
        $request->code = $token;

        /**
         * Send the request.
         */
        $response = $service->getUserToken($request);

        echo '<pre>';
        print_r($response);
        echo '<pre>';
        exit;

Once I tried to put the recently fetched token on $request->code . Nothing changed. Can you help me go through it ? Thanks

mburton3969 commented 5 years ago

The Grant Code is sent back from Ebay when the user gives permission for the application to have access to their account.

As soon as they hit "Accept", a Grant Code is added to the redirect URL you setup in your Ebay account. It is added to the URL as a GET parameter.

My advice is to store this code in a $_SESSION variable and then when you get to the [get-user-token.php] script, you can use this as the $request->code value

Worked for me. Hope this helps!