-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: Add expiry to oauth arguments for refresh #155
Conversation
Currently the oauth flow does not do refreshes if the access token is expired, as Credentails() does't know when the access token expires, so it completely skips refreshing. Credentails() will only refresh when a expiry datetime object is passed, so here we add an oauth argument for expiry, and pass it to Credentails().
Kudos, SonarCloud Quality Gate passed! |
@JichaoS thanks for the PR! I've only used a service account so I'm not familiar with this flow. Can you help me understand how this works, does the library do the refresh automatically if you provide the expiry parameter? I wasn't able to easily find this in their docs. It sounds like currently the tap would fail if the token expired mid sync, is that right? So after this PR merges, if a expiry is provided, the sync would start and if the token expires mid run it will refresh itself and continue. Is that true or will it only do it on initialization? |
@pnadolny13 ty for the review!
Yes exactly
I suspect that's the case, but haven't tried it out. FWIW the code here suggests that is the case: https://github.com/googleapis/google-auth-library-python/blob/main/google/auth/transport/requests.py#L552 The case I'm targeting is getting the library to refresh the token when handed an already-expired access token along with a refresh token. The library currently tries to use the access token, and gets back an error saying the oauth token is invalid, even if the user provided a refresh token (and other refresh credentials) |
@JichaoS that makes sense, I'm fine with your approach but had another crazy idea, curious what you think - I wonder if hardcoding (or defaulting) the |
The method that was previously used to manage OAuth tokens had issues with refreshing (see #155) and it expected an access token to be provided which is unnecessary.
This should now be resolved by #159. The access token is not needed when a refresh token is provided. |
Currently the oauth flow does not do refreshes if the access token is expired, as Credentails() does't know when the access token expires, so it completely skips refreshing.
Credentails() will only refresh when a expiry datetime object is passed, so here we add an oauth argument for expiry, and pass it to Credentails().