docs: Clarify return values of introspect_token()#943
Open
SyntaxColoring wants to merge 2 commits intooauthlib:masterfrom
Open
docs: Clarify return values of introspect_token()#943SyntaxColoring wants to merge 2 commits intooauthlib:masterfrom
SyntaxColoring wants to merge 2 commits intooauthlib:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Clarifies the RequestValidator.introspect_token() contract so implementers understand how to produce an “inactive” introspection response in oauthlib’s RFC6749 introspection endpoint.
Changes:
- Updates the
introspect_token()docstring to indicate that only active tokens should return a claims dict. - Documents that expired/unknown (inactive) tokens should return
None(resulting in"active": falsein the HTTP response).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
I was trying to implement a token introspection endpoint with the following flavor:
SHOULD NOT) in https://datatracker.ietf.org/doc/html/rfc7662."active": falseto prevent downstream resource servers from misinterpreting them as valid access tokens. (The RFC leaves it unclear how the token introspection endpoint ought to distinguish refresh tokens from access tokens. This was just my guess. Maybe there's a better way.)Here was my implementation attempt, which has a bug:
The bug in that code is that returning
active: Falsedoes not actually do anything. oauthlib always overridesactivetoTrue. The only way to return"active": falseover HTTP is for the Python code to returnNone.oauthlib/oauthlib/oauth2/rfc6749/endpoints/introspect.py
Lines 76 to 80 in a4689be
That wasn't clear in the oauthlib documentation, so this updates it.
(Documentation aside, I think this behavior is unfortunate because it prevents us from deliberately returning extra information about inactive tokens, but maybe that's just a bad thing to want to do.)