Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement OAuth2 user token autorefresh. #2039

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ewtoombs
Copy link

@ewtoombs ewtoombs commented Jan 19, 2023

To use OAuth2 properly, an OAuth2UserHandler must be used instead of a vanilla requests.Session. A session= argument has been supplied to tweepy.Client for this purpose. Now, if the Client.session isn't a vanilla requests.Session, this session is used for all authentication. This is actually how oauth1 should be done too.

OAuth2UserHandler has been given two more arguments: auto_refresh and token_updater. It has also been given a classmethod, from_token(), for restoring an OAuth2UserHandler from old data.

This code does not rely on requests/requests-oauthlib#511 , but the documentation I wrote for this code does assume behaviour resulting from it.

@ewtoombs ewtoombs force-pushed the refresh_token branch 4 times, most recently from 15111de to c983dc0 Compare January 20, 2023 15:39
@ewtoombs ewtoombs changed the title WIP: Implement OAuth2 user token autorefresh. Implement OAuth2 user token autorefresh. Jan 20, 2023
OAuth2 user authentication is now handled by OAuth2UserHandler as a session. To
make it work, pass an OAuth2UserHandler to the session argument of Client's
constructor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant