From 30483fff8787bab1bc78fc4bcf018ce6b02deb11 Mon Sep 17 00:00:00 2001 From: Lasse Mammen Date: Thu, 7 May 2020 16:34:35 +0100 Subject: [PATCH] Update error handling in BookboonProvider --- src/Client/Oauth/BookboonProvider.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Client/Oauth/BookboonProvider.php b/src/Client/Oauth/BookboonProvider.php index d0e593b..8a8bd2a 100644 --- a/src/Client/Oauth/BookboonProvider.php +++ b/src/Client/Oauth/BookboonProvider.php @@ -25,7 +25,7 @@ class BookboonProvider extends AbstractProvider public function __construct(array $options = [], array $collaborators = []) { - if (isset($options['baseUri']) && $options['baseUri'] != "") { + if (isset($options['baseUri']) && $options['baseUri'] !== "") { $parts = explode('://', $options['baseUri']); $this->protocol = $parts[0]; $this->host = $parts[1]; @@ -50,7 +50,7 @@ public function __construct(array $options = [], array $collaborators = []) */ public function getBaseAuthorizationUrl() { - return $this->protocol . "://" . $this->host . "/login/authorize"; + return "$this->protocol://$this->host/login/authorize"; } /** @@ -63,7 +63,7 @@ public function getBaseAuthorizationUrl() */ public function getBaseAccessTokenUrl(array $params) { - return $this->protocol . "://" . $this->host . "/login/access_token"; + return "$this->protocol://$this->host/login/access_token"; } /** @@ -74,7 +74,7 @@ public function getBaseAccessTokenUrl(array $params) */ public function getResourceOwnerDetailsUrl(AccessToken $token) { - return $this->protocol . "://" . $this->host . "/login/userinfo"; + return "$this->protocol://$this->host/login/userinfo"; } @@ -96,7 +96,7 @@ public function getAccessToken($grant, array $options = []) } if (is_array($options['scope'])) { - $options['scope'] = join($this->getScopeSeparator(), $options['scope']); + $options['scope'] = implode($this->getScopeSeparator(), $options['scope']); } return parent::getAccessToken($grant, $options); @@ -125,9 +125,9 @@ protected function getDefaultScopes() */ protected function checkResponse(ResponseInterface $response, $data) { - if (is_array($data) && isset($data['error'])) { + if (isset($data['errors'])) { throw new IdentityProviderException( - $data['error'] ?? $response->getReasonPhrase(), + $data['errors'][0]['title'] ?? $response->getReasonPhrase(), $response->getStatusCode(), $response->getBody() );