mozilla / mozilla-django-oidc

A django OpenID Connect library
https://mozilla-django-oidc.readthedocs.io
Mozilla Public License 2.0
445 stars 166 forks source link

get_token not properly reporting errors #463

Open dopry opened 2 years ago

dopry commented 2 years ago

at https://github.com/mozilla/mozilla-django-oidc/blob/21ca7b80e63ba344685133db67567a0768d39f69/mozilla_django_oidc/auth.py#L232, raise for status is called which does check the status properly, but doesn't properly extract the error message. the token request endpoint returns errors in an error property as per https://datatracker.ietf.org/doc/html/rfc6749#section-5.2. However requests.models.Response.raise_for_status looks for a reason property, https://github.com/psf/requests/blob/bda7f0171f8bba17989d3a2c28dfa9a9261b1b65/requests/models.py#L994.

The error handling in get_token should be updated to return the specific error in the authentication process.