fix(sdk): resend the OAuth resource on token refresh - #19
Merged
Conversation
Refreshes went to the token endpoint without the RFC 8707 resource, so an authorization server that applies a default resource to resource-less requests could re-bind the refreshed REST token to another audience. OAuthCredential now carries the resource from the code exchange, persists it, and passes it to authlib's refresh_token. Credentials stored before this release have no resource and keep the previous behavior.
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.
Summary
OAuthCredentialgains an optionalresourcefield (RFC 8707), filled in byexchange_codeand persisted to the config file.refresh/refresh_asyncpassresource=credential.resourceto authlib'srefresh_token, so it lands in the form body. Omitted whenNone.resource; they load withNoneand refresh exactly as before until the nextdiscolike auth login.base_urlas the resource intoexchange_code.Why
Refreshes went to the token endpoint without
resource. We are about to enable PropelAuth's MCP default resource (project-wide, pointed at the MCP audience). If PropelAuth applies that default to resource-lessrefresh_tokengrants, every refreshed REST token would come back with the MCPaudand be rejected by the REST API. Sendingresourceon refresh is spec-correct regardless of how PropelAuth answers.Test plan
resource; sync and async refresh send it and keep it on the rotated credential; config round-trip includes it; legacy config without it loads asNone.resourcekey.ruff checkandruff format --checkclean.discolike auth loginagainst dev, wait for a refresh, confirm REST still 200 with default resource enabled.Greptile Summary
This PR preserves the RFC 8707 resource associated with an OAuth credential and resends it during synchronous and asynchronous token refreshes.
resourcefield to persisted OAuth credentials.Confidence Score: 5/5
The PR appears safe to merge; the OAuth resource is preserved through configuration and token rotation without changing legacy refresh requests.
All affected login, persistence, synchronous refresh, asynchronous refresh, and request-triggered refresh paths retain the resource, while credentials lacking it continue to omit the parameter as intended.
Important Files Changed
Reviews (1): Last reviewed commit: "fix(sdk): resend the OAuth resource on t..." | Re-trigger Greptile
Context used (3)