bigcommerce-api-php icon indicating copy to clipboard operation
bigcommerce-api-php copied to clipboard

getAuthToken() always throws redirect_uri mismatch error

Open nbennett25 opened this issue 3 years ago • 0 comments

Expected behavior

App is installed

Actual behavior

Parameter redirect_uri does not match registered URI error thrown, app is not installed.

Steps to reproduce behavior

Using bigcommerce/api version 3.3.1. When using the README.md instructions to get the App's auth token, the "Parameter redirect_uri does not match registered URI" error is always thrown.

I've tried using trailing slashes and not, changing apps, etc. but when I add the Loadcallback URI from the App to the redirect_uri parameter in the code below, sending the request to getAuthToken() always fails.

use Bigcommerce\Api\Client as Bigcommerce;

$object = new \stdClass();
$object->client_id = '[client id from test app]';
$object->client_secret = '[client secret from test app]';
$object->redirect_uri = '[copy pasted from Load Callback URL]';
$object->code = $request->get('code');
$object->context = $request->get('context');
$object->scope = $request->get('scope');

$authTokenResponse = Bigcommerce::getAuthToken($object);

// fails here - getAuthToken returns false

Bigcommerce::configure(array(
    'client_id' => 'xxxxxxxx',
    'auth_token' => $authTokenResponse->access_token,
    'store_hash' => 'xxxxxxx'
));

nbennett25 avatar Oct 18 '22 16:10 nbennett25