diff --git a/Provider.php b/Provider.php index 90d4b3b..b7e3a2f 100644 --- a/Provider.php +++ b/Provider.php @@ -45,11 +45,19 @@ protected function getOktaUrl() } /** - * {@inheritdoc} + * Returns the Auth Server ID based on config option 'auth_server_id'. + * + * @return string */ protected function getAuthServerId() { - return $this->getConfig('auth_server_id', 'default'); + $auth_server_id = $this->getConfig('auth_server_id', null); + + if ($auth_server_id) { + return $auth_server_id.'/'; + } + + return ''; } /** @@ -65,7 +73,7 @@ public static function additionalConfigKeys() */ protected function getAuthUrl($state) { - return $this->buildAuthUrlFromBase($this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'/v1/authorize', $state); + return $this->buildAuthUrlFromBase($this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'v1/authorize', $state); } /** @@ -81,7 +89,7 @@ protected function getTokenUrl() */ protected function getUserByToken($token) { - $response = $this->getHttpClient()->get($this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'/v1/userinfo', [ + $response = $this->getHttpClient()->get($this->getOktaUrl().'/oauth2/'.$this->getAuthServerId().'v1/userinfo', [ 'headers' => [ 'Authorization' => 'Bearer '.$token, ], diff --git a/README.md b/README.md index ad70078..17f7188 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,9 @@ Please see the [Base Installation Guide](https://socialiteproviders.com/usage/), #### Custom Auth Server -If you're using a custom auth server, pass the `auth_server_id` config option. For more information, see the [okta docs](https://developer.okta.com/docs/concepts/auth-servers/). +If you're using Okta Developer you should set `auth_server_id` config option appropriately. It should be set to "default", or to the server id of your Custom Authorization Server. + +For more information, see the [okta docs](https://developer.okta.com/docs/concepts/auth-servers/). ### Add provider event listener