Skip to content

Commit ec1b2cc

Browse files
committed
Changed oauth flow and signing http requests
1 parent 0d57a50 commit ec1b2cc

File tree

110 files changed

+7515
-9040
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+7515
-9040
lines changed

README.md

+30-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ however most of them comes with all issues of auto generated code.
88
- hardcoded `guzzlehttp/guzzle` or `aws/aws-sdk-php` dependency
99
- legacy code base (7.2)
1010
- no logger
11+
- SDK's are oriented around single seller which is not suitable for bigger systems
12+
- missing or lacking support for `client_credentials` grant type
13+
- not all API covered
1114

15+
This API goal is to resolve all above mentioned issues.
1216

1317
### Development
1418

@@ -34,7 +38,10 @@ composer generate
3438
```php
3539
<?php
3640

37-
use AmazonPHP\SellingPartner\Api\CatalogApi\CatalogItemSDK;
41+
use AmazonPHP\SellingPartner\Api\AuthorizationSDK;
42+
use AmazonPHP\SellingPartner\Api\CatalogItemSDK;
43+
use AmazonPHP\SellingPartner\Marketplace;
44+
use AmazonPHP\SellingPartner\Regions;
3845
use Buzz\Client\Curl;
3946
use AmazonPHP\SellingPartner\Exception\ApiException;
4047
use AmazonPHP\SellingPartner\OAuth;
@@ -47,23 +54,32 @@ require_once __DIR__ . '/vendor/autoload.php';
4754
$factory = new Psr17Factory();
4855
$client = new Curl($factory);
4956

50-
$catalog = new CatalogItemSDK(
51-
new OAuth(
52-
$client,
53-
new HttpFactory($factory, $factory),
54-
Configuration::forIAMUser(
55-
'client_id',
56-
'client_secret',
57-
'eu-west-1',
58-
'access_key',
59-
'secret_key'
60-
),
61-
'seller_refresh_token'
57+
$oauth = new OAuth(
58+
$client,
59+
$httpFactory = new HttpFactory($factory, $factory),
60+
$config = Configuration::forIAMUser(
61+
'lwaClientID',
62+
'lwaClientID',
63+
'awsAccessKey',
64+
'awsSecretKey'
6265
)
6366
);
6467

68+
$accessToken = $oauth->exchangeRefreshToken('seller_oauth_refresh_token');
69+
70+
$catalog = new CatalogItemSDK(
71+
$client,
72+
new HttpFactory($factory, $factory),
73+
$config
74+
);
75+
6576
try {
66-
$item = $catalog->getCatalogItem($marketplace_id = 'A1C3SOZRARQ6R3', $asin = 'B07W13KJZC');
77+
$item = $catalog->getCatalogItem(
78+
$accessToken,
79+
Regions::NORTH_AMERICA,
80+
$marketplaceId = Marketplace::US()->id(),
81+
$asin = 'B07W13KJZC'
82+
);
6783
dump($item);
6884
} catch (ApiException $exception) {
6985
dump($exception->getMessage());

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
"scripts": {
3737
"clean": [
38-
"rm -rf src/AmazonPHP/SellingPartner/API",
38+
"rm -rf src/AmazonPHP/SellingPartner/Api",
3939
"rm -rf src/AmazonPHP/SellingPartner/Model"
4040
],
4141
"generate": [

0 commit comments

Comments
 (0)