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.
  • Loading branch information
zapad committed Apr 19, 2017
1 parent ac1830a commit fde7079
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,14 @@ protected function parseResponse(ResponseInterface $response)
throw $e;
}

if ($response->getStatusCode() == 500) {
throw new UnexpectedValueException(
'An OAuth server error was encountered that did not contain a JSON body',
0,
$e
);
}

return $content;
}
}
Expand Down

0 comments on commit fde7079

Please sign in to comment.