Skip to content

Commit

Permalink
Merge pull request #193 from gayanhewa/FixGetAuthToken
Browse files Browse the repository at this point in the history
Fix the get auth token and update the README
  • Loading branch information
Alyss Noland authored Mar 7, 2017
2 parents 9d66413 + 89ac39c commit 7d1504f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,27 @@ Bigcommerce::configure(array(
~~~

### OAuth

In order to obtain the auth_token you would consume `Bigcommerce::getAuthToken` method

~~~php

$object = new \stdClass();
$object->client_id = 'xxxxxx';
$object->client_secret = 'xxxxx;
$object->redirect_uri = 'https://app.com/redirect';
$object->code = $request->get('code');
$object->context = $request->get('context');
$object->scope = $request->get('scope');

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

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

~~~

Connecting to the store
Expand Down
1 change: 0 additions & 1 deletion src/Bigcommerce/Api/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ public static function getAuthToken($object)
{
$context = array_merge(array('grant_type' => 'authorization_code'), (array)$object);
$connection = new Connection();
$connection->useUrlEncoded();

return $connection->post(self::$login_url . '/oauth2/token', $context);
}
Expand Down

0 comments on commit 7d1504f

Please sign in to comment.