Colin-b / requests_auth

Authentication classes to be used with requests
MIT License
35 stars 13 forks source link

Add ability to provide a refresh token #70

Closed da1910 closed 8 months ago

da1910 commented 2 years ago

It would be helpful if there were an obvious way to provide a refresh token when creating a session. For our use case we do not support any Auth flows other than Authorization Code, but for headless execution we need to be able to persist a token somewhere and provide it.

Ideally this would be an argument to the constructors for OAuth2AuthorizationCodeFlow and the PKCE variant, but a set_refresh_token() method, or a new subclass would also be OK.

I'm happy to prepare a PR if there's a preferred approach.

Colin-b commented 8 months ago

Hello,

You can always implement your own token cache and have get_token method returning whatever token you want to use. Refer to documentation on how to assign a token cache.