Azure-Samples / msdocs-django-web-app-managed-identity

Shows Python (Django framework) used with three Azure services.
MIT License
0 stars 4 forks source link

How to periodically refresh tokens? #19

Open nikhilweee opened 2 months ago

nikhilweee commented 2 months ago

get_token() will only be called once when the app starts. What's the best way to periodically refresh tokens? I see a line that suggests writing a django middleware. Is there an example available? https://github.com/Azure-Samples/msdocs-django-web-app-managed-identity/blob/c6ca188c2b6c93e0852dae5e9f8112852b2aebcf/azureproject/get_token.py#L5

bobtabor-msft commented 2 months ago

@pamelafox Would you consider commenting on this issue? Thank you!

pamelafox commented 2 months ago

I actually just implemented that today! Here's how I did it for Django: https://github.com/pamelafox/django-quiz-app/pull/53/files#diff-349d3196c8f51b935294f476e30a9ba340b7e1256c9de27e108247bb0c079c28

I need to check my deploy in 24 hours and confirm it's still working, however.