Skip to content

Commit

Permalink
Merge pull request #8 from waytohealth/api-update
Browse files Browse the repository at this point in the history
Update Provider for Omron API changes
  • Loading branch information
mcgrogan91 authored Jul 3, 2023
2 parents 384e8be + 47d17fc commit 72fa807
Show file tree
Hide file tree
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
Expand Up @@ -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.
*/
Expand All @@ -42,7 +47,7 @@ public function getBaseAuthorizationUrl()
*/
public function getBaseAccessTokenUrl(array $params)
{
return $this->authHostname . '/connect/token';
return $this->tokenHostname . '/connect/token';
}

/**
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions test/src/Provider/OmronTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);

Expand Down Expand Up @@ -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']);
}

Expand All @@ -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']);
}

Expand Down

0 comments on commit 72fa807

Please sign in to comment.