Skip to content

Commit

Permalink
Update BookboonProvider to properly catch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lkm committed Jun 4, 2020
1 parent 527988b commit b91efd0
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/Client/Oauth/BookboonProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ class BookboonProvider extends AbstractProvider
*/
private $scopes = null;

/**
* @var string
*/
private $responseError = 'error';

/**
* @var string
*/
private $responseCode;


public function __construct(array $options = [], array $collaborators = [])
{
Expand All @@ -67,8 +57,6 @@ public function __construct(array $options = [], array $collaborators = [])
protected function getConfigurableOptions()
{
return [
'responseError',
'responseCode',
'responseResourceOwnerId',
'scopes',
];
Expand Down Expand Up @@ -133,10 +121,13 @@ protected function getDefaultScopes()
*/
protected function checkResponse(ResponseInterface $response, $data)
{
if (!empty($data[$this->responseError])) {
$error = $data[$this->responseError];
$code = $this->responseCode ? $data[$this->responseCode] : 0;
throw new IdentityProviderException($error, $code, $data);
if (!empty($data['errors'])) {
$errorTitle = isset($data['errors'][0]['title']) ? $data['errors'][0]['title'] : $response->getReasonPhrase();
throw new IdentityProviderException(
$errorTitle,
$response->getStatusCode(),
$response->getBody()
);
}
}

Expand Down Expand Up @@ -242,4 +233,4 @@ public function generateRandomState()
{
return $this->getRandomState();
}
}
}

0 comments on commit b91efd0

Please sign in to comment.