Skip to content

Commit

Permalink
Merge pull request #131 from asgoodasnu/feature/FixForAuthUrl
Browse files Browse the repository at this point in the history
Feature/fix for auth url
  • Loading branch information
jlevers authored Dec 14, 2021
2 parents 52f12a2 + ff853d7 commit 60257cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore

.idea/
composer.phar
/vendor/
/.openapi-generator/
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jlevers/selling-partner-api",
"version": "4.2.2",
"version": "4.2.3",
"description": "PHP client for Amazon's Selling Partner API",
"keywords": [
"api",
Expand All @@ -27,7 +27,7 @@
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.0|^7.0",
"phpoffice/phpspreadsheet": "^1.18",
"phpoffice/phpspreadsheet": "^1.19",
"aws/aws-sdk-php": "^3.185"
},
"require-dev": {
Expand Down
5 changes: 4 additions & 1 deletion lib/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Authentication
private $lwaClientId;
private $lwaClientSecret;
private $lwaRefreshToken = null;
private $lwaAuthUrl = null;
private $endpoint;

private $onUpdateCreds;
Expand Down Expand Up @@ -51,6 +52,7 @@ public function __construct(array $configurationOptions)
{
$this->client = new Client();

$this->lwaAuthUrl = $configurationOptions['lwaAuthUrl'] ?? "https://api.amazon.com/auth/o2/token";
$this->lwaRefreshToken = $configurationOptions['lwaRefreshToken'] ?? null;
$this->onUpdateCreds = $configurationOptions['onUpdateCredentials'];
$this->lwaClientId = $configurationOptions['lwaClientId'];
Expand Down Expand Up @@ -93,7 +95,7 @@ public function requestLWAToken(): array
$jsonData["refresh_token"] = $this->lwaRefreshToken;
}

$res = $this->client->post("https://api.amazon.com/auth/o2/token", [
$res = $this->client->post($this->lwaAuthUrl, [
\GuzzleHttp\RequestOptions::JSON => $jsonData,
]);

Expand Down Expand Up @@ -303,6 +305,7 @@ public function getRestrictedDataToken(string $path, string $method, ?bool $gene
"lwaClientId" => $this->lwaClientId,
"lwaClientSecret" => $this->lwaClientSecret,
"lwaRefreshToken" => $this->lwaRefreshToken,
"lwaAuthUrl" => $this->lwaAuthUrl,
"awsAccessKeyId" => $this->awsAccessKeyId,
"awsSecretAccessKey" => $this->awsSecretAccessKey,
"accessToken" => $standardCredentials->getSecurityToken(),
Expand Down

0 comments on commit 60257cc

Please sign in to comment.