Skip to content
Snippets Groups Projects
Commit b4cda492 authored by Simon Künzel's avatar Simon Künzel
Browse files

Better handling of OAuth servers response

parent 573ca987
No related branches found
No related tags found
No related merge requests found
......@@ -396,10 +396,21 @@ else:
raise ValueError("Session auth scope set to something different than rwth or moodle")
try:
token_response = __make_oauth_request("token", code=api_session.running_oauth_code, grant_type="device")
if token_response.get("status") != "ok":
# TODO debug statement
print(f"Got non-'ok' status for OAuth: {token_response}")
match token_response.get("status"):
case "error: authorization pending.":
return
case "error: device code invalid.":
# We get this when the user declines the authorization
api_session.running_oauth_code = None
api_session.running_oauth_scope = None
return
case "error: slow down.":
ERROR_NOTIFIER.notify("Warning: Got 'error: slow down.' from RWTH OAuth server")
return
case "ok":
pass
case _:
raise Exception(f"Got unknown status from RWTH OAuth server: {token_response.get("status")}. Full response: {token_response}")
api_session.running_oauth_code = None
api_session.running_oauth_scope = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment