mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-07 18:14:10 +00:00
better error messages on oauth errors
This commit is contained in:
@@ -302,7 +302,15 @@ class HubAuth(SingletonConfigurable):
|
||||
elif r.status_code >= 400:
|
||||
app_log.warning("Failed to check authorization: [%i] %s", r.status_code, r.reason)
|
||||
app_log.warning(r.text)
|
||||
raise HTTPError(500, "Failed to check authorization")
|
||||
msg = "Failed to check authorization"
|
||||
# pass on error_description from oauth failure
|
||||
try:
|
||||
description = r.json().get("error_description")
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
msg += ": " + description
|
||||
raise HTTPError(500, msg)
|
||||
else:
|
||||
data = r.json()
|
||||
|
||||
@@ -847,6 +855,11 @@ class HubOAuthCallbackHandler(HubOAuthenticated, RequestHandler):
|
||||
|
||||
@coroutine
|
||||
def get(self):
|
||||
error = self.get_argument("error", False)
|
||||
if error:
|
||||
msg = self.get_argument("error_description", error)
|
||||
raise HTTPError(400, "Error in oauth: %s" % msg)
|
||||
|
||||
code = self.get_argument("code", False)
|
||||
if not code:
|
||||
raise HTTPError(400, "oauth callback made without a token")
|
||||
|
Reference in New Issue
Block a user