Description
I'm writing an application that uses an expiring user access token to authenticate a GitHub App on behalf of a user. This process uses the OAuth web flow to generate an access token and refresh token; these are valid for 8 hours and 6 months, respectively. I want to store the access and refresh tokens so that users don't have to log in each time they use the app.
I see that githubkit has OAuthWebAuthStrategy
, which is useful for the initial login; however, it seems like the access and refresh tokens are stored in private variables in OAuthWebAuth
, and I don't see an obvious public way to access them or to force it to fetch them. I also couldn't find an AuthStrategy
that takes an access or refresh token as the input.
Ideally, this is the sort of code I would like to be able to write:
# initial login
github = GitHub(OAuthWebAuthStrategy(client_id, client_secret, code))
access_token, refresh_token = github.get_app_user_access_token()
# subsequent usages
github = GitHub(AppUserAuthStrategy(client_id, client_secret, access_token, refresh_token))
GitHub app user auth flow docs:
For comparison, here's how PyGithub's app user authentication works:
https://pygithub.readthedocs.io/en/stable/examples/Authentication.html#app-user-authentication