From 47d17fcfcc9e8fd1820768586039e6fc418a1631 Mon Sep 17 00:00:00 2001 From: Kyle McGrogan Date: Wed, 28 Jun 2023 16:10:16 -0400 Subject: [PATCH] Update Provider for Omron API changes Omron is updating their API, and their authentication and token addresses are no longer the same. Update the provider to support this new behavior. --- src/Provider/Omron.php | 9 +++++++-- test/src/Provider/OmronTest.php | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Provider/Omron.php b/src/Provider/Omron.php index 3d297d3..fca3a0d 100644 --- a/src/Provider/Omron.php +++ b/src/Provider/Omron.php @@ -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); diff --git a/test/src/Provider/OmronTest.php b/test/src/Provider/OmronTest.php index 2795398..44496a2 100644 --- a/test/src/Provider/OmronTest.php +++ b/test/src/Provider/OmronTest.php @@ -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']); }