mozilla / mozilla-django-oidc

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

How to renew the access_token (using the refresh_token)? #501

Open afmorielo opened 1 year ago

afmorielo commented 1 year ago

I have a web application, A, that utilizes mozilla-django-oidc 3.0.0 to authenticate with an OIDC provider, specifically Keycloak. Application A needs to communicate with application B, which does not use mozilla-django-oidc, but also authenticates with the same OIDC provider.

In the request sent from application A to application B, we include the access_token of the logged-in user. This access_token is then used by application B to grant access to protected resources.

Everything is functioning correctly, except for the issue that the access_token expires. When this happens, we are currently unable to use mozilla-django-oidc to automatically renew the access_token using the refresh_token.

As a temporary solution, we have made a small modification in the auth.py file to store additional variables in the Django Session. Later on, we utilize these variables in a custom function that we created specifically to handle the renewal of the access_token.

modify_mozilla_django_oidc

My question is: does mozilla-django-oidc provide any built-in functionality or feature to handle this specific case?