Skip to content

Commit 25a7a19

Browse files
committed
handle subdomain change
1 parent 6b06dfc commit 25a7a19

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

src/AmoCRM/OAuth/AmoCRMOAuth.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
4141
use League\OAuth2\Client\Token\AccessToken;
4242
use League\OAuth2\Client\Token\AccessTokenInterface;
43-
4443
use Throwable;
44+
4545
use function sprintf;
4646

4747
/**
@@ -164,16 +164,26 @@ public function getAccessTokenByRefreshToken(AccessTokenInterface $accessToken):
164164
'refresh_token' => $accessToken->getRefreshToken(),
165165
]);
166166
} catch (IdentityProviderException $e) {
167-
if (in_array(
168-
$e->getCode(), [StatusCodeInterface::STATUS_NOT_FOUND, StatusCodeInterface::STATUS_UNAUTHORIZED], true
169-
)) {
167+
if (
168+
in_array(
169+
$e->getCode(),
170+
[
171+
StatusCodeInterface::STATUS_NOT_FOUND,
172+
StatusCodeInterface::STATUS_UNAUTHORIZED,
173+
],
174+
true
175+
)
176+
) {
170177
$accountDomainModel = $this->getAccountDomainByRefreshToken($accessToken);
171178
$this->setBaseDomain($accountDomainModel->getDomain());
172179

173180
try {
174-
$accessToken = $this->oauthProvider->getAccessToken(new RefreshToken(), [
175-
'refresh_token' => $accessToken->getRefreshToken(),
176-
]);
181+
$accessToken = $this->oauthProvider->getAccessToken(
182+
new RefreshToken(),
183+
[
184+
'refresh_token' => $accessToken->getRefreshToken(),
185+
]
186+
);
177187
} catch (IdentityProviderException $e) {
178188
throw new AmoCRMoAuthApiException(
179189
$e->getMessage(),

0 commit comments

Comments
 (0)