Skip to content

Commit 1c059bc

Browse files
authored
Merge pull request #2 from sendynl/change-token-refresh-url
Use the correct URL when refreshing access tokens
2 parents e09b5ca + 33ff698 commit 1c059bc

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/Connection.php

+3-10
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ class Connection
3333

3434
private const TOKEN_URL = '/oauth/token';
3535

36-
private const REFRESH_URL = '/oauth/token/refresh';
37-
38-
private const VERSION = '1.0';
36+
private const VERSION = '1.0.1';
3937

4038
/** @var Client|null */
4139
private ?Client $client = null;
@@ -289,22 +287,17 @@ private function acquireAccessToken(): void
289287
'client_secret' => $this->clientSecret,
290288
'code' => $this->authorizationCode,
291289
];
292-
293-
$response = $this->getClient()->post(self::BASE_URL . self::TOKEN_URL, ['form_params' => $parameters]);
294290
} else {
295291
$parameters = [
296292
'refresh_token' => $this->refreshToken,
297293
'grant_type' => 'refresh_token',
298294
'client_id' => $this->clientId,
299295
'client_secret' => $this->clientSecret,
300296
];
301-
302-
$response = $this->getClient()->post(
303-
self::BASE_URL . self::REFRESH_URL,
304-
['form_params' => $parameters]
305-
);
306297
}
307298

299+
$response = $this->getClient()->post(self::BASE_URL . self::TOKEN_URL, ['form_params' => $parameters]);
300+
308301
Message::rewindBody($response);
309302

310303
$responseBody = $response->getBody()->getContents();

tests/ConnectionTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public function testUserAgentIsSet(): void
2323
$connection = new Connection();
2424

2525
$this->assertEquals(
26-
sprintf('Sendy/1.0 PHP/%s', phpversion()),
26+
sprintf('Sendy/1.0.1 PHP/%s', phpversion()),
2727
$connection->getClient()->getConfig('headers')['User-Agent']
2828
);
2929

3030
$connection = new Connection();
3131
$connection->setOauthClient(true);
3232

3333
$this->assertEquals(
34-
sprintf('Sendy/1.0 PHP/%s OAuth/2.0', phpversion()),
34+
sprintf('Sendy/1.0.1 PHP/%s OAuth/2.0', phpversion()),
3535
$connection->getClient()->getConfig('headers')['User-Agent']
3636
);
3737
}
@@ -288,7 +288,7 @@ public function testTokensAreAcquiredWithRefreshToken(): void
288288
$this->assertEquals(time() + 3600, $connection->getTokenExpires());
289289

290290
$this->assertEquals(
291-
'https://app.sendy.nl/oauth/token/refresh',
291+
'https://app.sendy.nl/oauth/token',
292292
(string) $mockHandler->getLastRequest()->getUri()
293293
);
294294
}

0 commit comments

Comments
 (0)