Skip to content

Commit 4c515da

Browse files
committed
Switch to the new Authorization Service hostname (https://api.npr.org/authorization/ -> https://authorization.api.npr.org) - closes DIG-9202
1 parent a3b9458 commit 4c515da

12 files changed

+20
-19
lines changed

docs/NPR-One-Interfaces-ConfigInterface.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ grant type. Currently, client credentials tokens never expire, so hard-coding it
6666

6767

6868

69-
### getNprApiHost
69+
### getNprAuthorizationServiceHost
7070

71-
string NPR\One\Interfaces\ConfigInterface::getNprApiHost()
72-
73-
Returns the NPR One API Hostname, useful for testing on staging environments. Most consumers will want to
74-
hard-code this to always return `https://api.npr.org`. Please do not include a trailing slash.
71+
string NPR\One\Interfaces\ConfigInterface::getNprAuthorizationServiceHost()
7572

73+
Returns the NPR One Authorization Service hostname, useful for testing on staging environments.
7674

75+
Most consumers will want to hard-code this to always return `https://authorization.api.npr.org`.
76+
Please do not include a trailing slash.
7777

7878
* Visibility: **public**
7979

examples/ConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getClientCredentialsToken()
3535
/**
3636
* @inheritdoc
3737
*/
38-
public function getNprApiHost()
38+
public function getNprAuthorizationServiceHost()
3939
{
4040
return 'https://api.npr.org';
4141
}

src/Controllers/AbstractOAuth2Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ final protected function createAccessToken($grantType, $additionalParams = [])
225225

226226
/** @var Client $client */
227227
$client = DI::container()->get(Client::class);
228-
$response = $client->request('POST', $this->config->getNprApiHost() . '/authorization/v2/token', [
228+
$response = $client->request('POST', $this->config->getNprAuthorizationServiceHost() . '/v2/token', [
229229
'headers' => $this->headers,
230230
'form_params' => array_merge([
231231
'client_id' => $this->config->getClientId(),

src/Controllers/AuthCodeController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function startAuthorizationGrant(array $scopes)
111111
'scope' => join(' ', $scopes)
112112
];
113113

114-
return $this->getConfigProvider()->getNprApiHost() . '/authorization/v2/authorize?' . http_build_query($queryParams);
114+
return $this->getConfigProvider()->getNprAuthorizationServiceHost() . '/v2/authorize?' . http_build_query($queryParams);
115115
}
116116

117117
/**

src/Controllers/DeviceCodeController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function createDeviceCode(array $scopes)
8585
{
8686
/** @var Client $client */
8787
$client = DI::container()->get(Client::class);
88-
$response = $client->request('POST', $this->getConfigProvider()->getNprApiHost() . '/authorization/v2/device', [
88+
$response = $client->request('POST', $this->getConfigProvider()->getNprAuthorizationServiceHost() . '/v2/device', [
8989
'headers' => $this->getHeaders(),
9090
'form_params' => [
9191
'client_id' => $this->getConfigProvider()->getClientId(),

src/Controllers/LogoutController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private function revokeToken($token, $isRefreshToken = false)
7575

7676
/** @var Client $client */
7777
$client = DI::container()->get(Client::class);
78-
$response = $client->request('POST', $this->getConfigProvider()->getNprApiHost() . '/authorization/v2/token/revoke', [
78+
$response = $client->request('POST', $this->getConfigProvider()->getNprAuthorizationServiceHost() . '/v2/token/revoke', [
7979
'headers' => [
8080
'Authorization' => 'Bearer ' . $this->getConfigProvider()->getClientCredentialsToken()
8181
],

src/Interfaces/ConfigInterface.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ public function getClientSecret();
4242
public function getClientCredentialsToken();
4343

4444
/**
45-
* Returns the NPR One API Hostname, useful for testing on staging environments. Most consumers will want to
46-
* hard-code this to always return `https://api.npr.org`. Please do not include a trailing slash.
45+
* Returns the NPR One Authorization Service hostname, useful for testing on staging environments.
46+
* Most consumers will want to hard-code this to always return `https://authorization.api.npr.org`.
47+
* Please do not include a trailing slash.
4748
*
4849
* @return string
4950
*/
50-
public function getNprApiHost();
51+
public function getNprAuthorizationServiceHost();
5152

5253
/**
5354
* Returns the host (or path) of the NPR One application (the client/frontend). This is where the `authorization_code`

tests/unit/AuthCodeControllerTests.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function setUp()
5252

5353
$this->mockConfig = $this->getMock(ConfigInterface::class);
5454
$this->mockConfig->method('getClientId')->willReturn(self::$clientId);
55-
$this->mockConfig->method('getNprApiHost')->willReturn('https://api.npr.org');
55+
$this->mockConfig->method('getNprAuthorizationServiceHost')->willReturn('https://authorization.api.npr.org');
5656
$this->mockConfig->method('getClientUrl')->willReturn('https://one.example.com');
5757
$this->mockConfig->method('getAuthCodeCallbackUrl')->willReturn('https://one.example.com/oauth2/callback');
5858
$this->mockConfig->method('getCookieDomain')->willReturn('.example.com');
@@ -170,7 +170,7 @@ public function testStartAuthorizationGrant()
170170

171171
$url = $controller->startAuthorizationGrant(['fake_scope']);
172172

173-
$this->assertContains('/authorization/v2/authorize', $url);
173+
$this->assertContains('/v2/authorize', $url);
174174
$this->assertContains('client_id=' . self::$clientId, $url);
175175
$this->assertContains('redirect_uri=', $url);
176176
$this->assertContains('state=', $url);

tests/unit/CustomControllerTests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function setUp()
4242

4343
$this->mockConfig = $this->getMock(ConfigInterface::class);
4444
$this->mockConfig->method('getClientId')->willReturn(self::$clientId);
45-
$this->mockConfig->method('getNprApiHost')->willReturn('https://api.npr.org');
45+
$this->mockConfig->method('getNprAuthorizationServiceHost')->willReturn('https://authorization.api.npr.org');
4646
$this->mockConfig->method('getCookieDomain')->willReturn('.example.com');
4747
$this->mockConfig->method('getEncryptionSalt')->willReturn('asYh&%D9ne!j8HKQ');
4848

tests/unit/DeviceCodeControllerTests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function setUp()
4444

4545
$this->mockConfig = $this->getMock(ConfigInterface::class);
4646
$this->mockConfig->method('getClientId')->willReturn(self::$clientId);
47-
$this->mockConfig->method('getNprApiHost')->willReturn('https://api.npr.org');
47+
$this->mockConfig->method('getNprAuthorizationServiceHost')->willReturn('https://authorization.api.npr.org');
4848
$this->mockConfig->method('getCookieDomain')->willReturn('.example.com');
4949
$this->mockConfig->method('getEncryptionSalt')->willReturn('asYh&%D9ne!j8HKQ');
5050

0 commit comments

Comments
 (0)