Skip to content

Commit

Permalink
Handling Oauth server internal errors.
Browse files Browse the repository at this point in the history
In situation when your OAuth server dies, the web server often gives you
default error 500 page. This page has text/html type, but current
behavior - is to try to parse in anyway.

The problem is: without handling the 500 code on non-json page, you will
get the type error on line 529, which can be hard to debug. So even if
this fix will not enough and you reject it, please at least make some
notice in documentation about handling such errors.

While you auth with Googe, Facebook, etc providers all is usually ok -
they test what they write. But there are lots of sites who provides the
oauth with awful and unstable realisation.

Style fix.
  • Loading branch information
zapad committed Mar 7, 2017
1 parent ac1830a commit 8b66b79
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,15 @@ protected function parseResponse(ResponseInterface $response)
throw $e;
}

if ($response->getStatusCode() == 500) {
throw new UnexpectedValueException(
'Failed to parse JSON and OAuth server response code is
500. It could be internal error on Oauth server.',
0,
$e
);
}

return $content;
}
}
Expand Down

0 comments on commit 8b66b79

Please sign in to comment.