Mark OAuth credentials that cannot be refreshed as in an error state
Sentry Issue: ARKINDEX-BACKEND-17Y
HTTPError: 400 Client Error: Bad Request for url: https://gitlab.com/oauth/token
(11 additional frame(s) were not displayed)
...
File "arkindex/dataimport/providers.py", line 131, in _get_project_from_repo
File "arkindex/dataimport/providers.py", line 118, in _get_gitlab_client
File "arkindex/users/providers.py", line 119, in refresh_token
File "arkindex/users/providers.py", line 146, in grant_token
File "requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
A hook event from a push to the Geosophy Classifier repo failed due to a HTTP 400 error when trying to refresh a GitLab token, with the following response :
{'error': 'invalid_grant', 'error_description': 'The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.'}
We could detect an invalid_grant
error and mark the OAuthCredentials
object as in an Error
state, which allows the user to both tell that something is wrong in the frontend and to fix it by re-connecting to GitLab. We can also throw an exception with a cleaner error message, so that the message gets emailed to the user using the existing error handling mechanism.
Edited by Erwan Rouchet