Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Changed oauth flow and signing http requests #3

Merged
merged 2 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 30 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ however most of them comes with all issues of auto generated code.
- hardcoded `guzzlehttp/guzzle` or `aws/aws-sdk-php` dependency
- legacy code base (7.2)
- no logger
- SDK's are oriented around single seller which is not suitable for bigger systems
- missing or lacking support for `client_credentials` grant type
- not all API covered

This API goal is to resolve all above mentioned issues.

### Development

Expand All @@ -34,7 +38,10 @@ composer generate
```php
<?php

use AmazonPHP\SellingPartner\Api\CatalogApi\CatalogItemSDK;
use AmazonPHP\SellingPartner\Api\AuthorizationSDK;
use AmazonPHP\SellingPartner\Api\CatalogItemSDK;
use AmazonPHP\SellingPartner\Marketplace;
use AmazonPHP\SellingPartner\Regions;
use Buzz\Client\Curl;
use AmazonPHP\SellingPartner\Exception\ApiException;
use AmazonPHP\SellingPartner\OAuth;
Expand All @@ -47,23 +54,32 @@ require_once __DIR__ . '/vendor/autoload.php';
$factory = new Psr17Factory();
$client = new Curl($factory);

$catalog = new CatalogItemSDK(
new OAuth(
$client,
new HttpFactory($factory, $factory),
Configuration::forIAMUser(
'client_id',
'client_secret',
'eu-west-1',
'access_key',
'secret_key'
),
'seller_refresh_token'
$oauth = new OAuth(
$client,
$httpFactory = new HttpFactory($factory, $factory),
$config = Configuration::forIAMUser(
'lwaClientID',
'lwaClientID',
'awsAccessKey',
'awsSecretKey'
)
);

$accessToken = $oauth->exchangeRefreshToken('seller_oauth_refresh_token');

$catalog = new CatalogItemSDK(
$client,
new HttpFactory($factory, $factory),
$config
);

try {
$item = $catalog->getCatalogItem($marketplace_id = 'A1C3SOZRARQ6R3', $asin = 'B07W13KJZC');
$item = $catalog->getCatalogItem(
$accessToken,
Regions::NORTH_AMERICA,
$marketplaceId = Marketplace::US()->id(),
$asin = 'B07W13KJZC'
);
dump($item);
} catch (ApiException $exception) {
dump($exception->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"scripts": {
"clean": [
"rm -rf src/AmazonPHP/SellingPartner/API",
"rm -rf src/AmazonPHP/SellingPartner/Api",
"rm -rf src/AmazonPHP/SellingPartner/Model"
],
"generate": [
Expand Down
Loading