Skip to content

Commit

Permalink
Update Provider for Omron API changes
Browse files Browse the repository at this point in the history
Omron is updating their API, and their authentication and token addresses are no longer the same. Update the provider to support this new behavior.
Kyle McGrogan authored and Kyle McGrogan committed Jun 28, 2023
1 parent 384e8be commit 47d17fc
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/Provider/Omron.php
Original file line number Diff line number Diff line change
@@ -18,6 +18,11 @@ class Omron extends AbstractProvider
*/
protected $authHostname;

/**
* @var string
*/
protected $tokenHostname;

/**
* @var string Key used in a token response to identify the resource owner.
*/
@@ -42,7 +47,7 @@ public function getBaseAuthorizationUrl()
*/
public function getBaseAccessTokenUrl(array $params)
{
return $this->authHostname . '/connect/token';
return $this->tokenHostname . '/connect/token';
}

/**
@@ -136,7 +141,7 @@ public function revoke(\League\OAuth2\Client\Token\AccessToken $accessToken)
{
$options = $this->optionProvider->getAccessTokenOptions($this->getAccessTokenMethod(), []);
$uri = $this->appendQuery(
$this->authHostname . '/connect/revocation',
$this->tokenHostname . '/connect/revocation',
$this->buildQueryString(['token' => $accessToken->getToken(), 'token_type_hint' => 'access_token'])
);
$request = $this->getRequest(self::METHOD_POST, $uri, $options);
10 changes: 8 additions & 2 deletions test/src/Provider/OmronTest.php
Original file line number Diff line number Diff line change
@@ -25,6 +25,8 @@ protected function setUp()
$this->provider = new Omron([
'clientId' => 'mock_client_id',
'clientSecret' => 'mock_secret',
'authHostname' => 'https://stg-oauth-website.ohiomron.com',
'tokenHostname' => 'https://stg-oauth.ohiomron.com/stg',
'redirectUri' => 'none',
]);

@@ -69,6 +71,8 @@ public function testGetAuthorizationUrl()
{
$url = $this->provider->getAuthorizationUrl();
$uri = parse_url($url);

$this->assertEquals('stg-oauth-website.ohiomron.com', $uri['host']);
$this->assertEquals('/connect/authorize', $uri['path']);
}

@@ -77,14 +81,16 @@ public function testGetBaseAccessTokenUrl()
$params = [];
$url = $this->provider->getBaseAccessTokenUrl($params);
$uri = parse_url($url);
$this->assertEquals('/connect/token', $uri['path']);

$this->assertEquals('stg-oauth.ohiomron.com', $uri['host']);
$this->assertEquals('/stg/connect/token', $uri['path']);
}

public function testGetResourceOwnerDetailsUrl()
{
$url = $this->provider->getResourceOwnerDetailsUrl($this->token);
$uri = parse_url($url);
$this->assertEquals('/v2/user', $uri['path']);
$this->assertEquals('', $uri['path']);
$this->assertEquals('action=getdevice&access_token=mock_token', $uri['query']);
}

0 comments on commit 47d17fc

Please sign in to comment.