You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello @lepture ! I was using authlib in a work project recently, and I found it hard to do some things. One of which is revoking tokens.
So I extended the StarletteOAuth2App class into this, adding a revoke method. Would you be open to adding something like this to the official implementation?
Also, separate point but I can also to dedicate work time to it, but are you open to adding some caching on top of the load_server_metadata method? Some basic LRU cache + timer maybe so that we don't have to make an extra network call EVERY time we call this method. It probably does not change at all in most cases.
classCustomStarletteOAuth2App(StarletteOAuth2App):
asyncdefrevoke_token(self, request: Request) ->None:
token=request.session.get("token")
# Nothing to do if no tokeniftokenisNoneortoken.get("access_token") isNone:
returnNonemetadata=awaitself.load_server_metadata()
revocation_endpoint=metadata.get("revocation_endpoint")
ifrevocation_endpointisNone:
raiseValueError("Revocation endpoint not found in server metadata")
asyncwithself._get_oauth_client(**metadata) asclient:
client=cast(AsyncOAuth2Client, client)
awaitclient.revoke_token(url=revocation_endpoint, token=token.get("access_token"))
returnNone
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello @lepture ! I was using authlib in a work project recently, and I found it hard to do some things. One of which is revoking tokens.
So I extended the StarletteOAuth2App class into this, adding a revoke method. Would you be open to adding something like this to the official implementation?
Also, separate point but I can also to dedicate work time to it, but are you open to adding some caching on top of the
load_server_metadata
method? Some basic LRU cache + timer maybe so that we don't have to make an extra network call EVERY time we call this method. It probably does not change at all in most cases.Beta Was this translation helpful? Give feedback.
All reactions