fix: issue with refreshing token when client_secret is not set#513
Merged
jpoehnelt merged 2 commits intogoogleworkspace:mainfrom Feb 27, 2025
Merged
Conversation
Contributor
Author
|
Hi @jpoehnelt 👋, Just a friendly ping — we’re encountering an issue with refreshing the token when using PKCE without setting a client secret. Resolving this in the OAuth2 for Apps Script would be the best solution for us, and I was wondering if you might have some time to look into the proposed changes in this PR. Any feedback or thoughts would be greatly appreciated! Thanks so much for your time and help. |
jpoehnelt
approved these changes
Feb 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for #506
Problem: The support for PKCE (Proof Key for Code Exchange) was introduced in the library, making the
client_secretfield optional (see commit e6afdfb). However, theclient_secretfield is still included in the list of validated fields in therefresh()method (Service.js#L667).Issue: When creating a client without setting a
client_secret(using PKCE for authentication), the token cannot be refreshed after its default expiration of one hour. This is because the validation check in therefresh()method expects aclient_secret, causing an error in the PKCE flow.Proposed Fix: Adjust the validation logic in the
refresh()method to account for the possibility that theclient_secretis not provided when using PKCE. This ensures that the token can still be refreshed in the absence of aclient_secret.