diff --git a/api/src/api/authentication.py b/api/src/api/authentication.py index 3c80f7bc30f41a2592a2e91bb500284e9ddbf522..0d880cf1a1ceb31d0246ff46401981fddfd2dc28 100644 --- a/api/src/api/authentication.py +++ b/api/src/api/authentication.py @@ -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}") - return + 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