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
Either in this repo, or on the Flask sample, what is the status of AuthKit integration?
I've been manually translating the node examples into Python, here is what I've come up with for the core parts.
I looked into the state of JWT in Python and the most up-to-date library currently is joserfc.
These are snippets for LiteStar framework, but the core parts should be extracted probably into the SDK, so not everyone has to look up the right JWKS validation libraries and methods.
from joserfc import jwt
from joserfc.jwk import KeySet
defcheck_session(connection: ASGIConnection) ->bool:
"""returns True if success, False if login is needed"""session=connection.sessionaccess_token_exp=session.get('access_token_exp')
ifaccess_token_expandtime.time() <access_token_exp:
returnTrue# get new access token using refresh tokentry:
workos_data=client.user_management.authenticate_with_refresh_token(
refresh_token=session.get('refresh_token')
)
update_session(connection, workos_data)
returnTrueexceptException:
returnFalse
defupdate_session(connection: ASGIConnection, workos_data) ->bool:
"""returns True if success, False if login is needed"""try:
claims_requests=jwt.JWTClaimsRegistry()
claims=jwt.decode(workos_data['access_token'], config.workos_key_set).claimsclaims_requests.validate(claims)
exceptException:
returnFalsenew_session=connection.session| {
'access_token_exp': claims['exp'],
'session_id': claims['sid'],
'refresh_token': workos_data['refresh_token'],
}
ifuser:=workos_data.get('user'):
new_session['user'] =userconnection.set_session(new_session)
returnTrue
The text was updated successfully, but these errors were encountered:
This is actually very timely, we recently released session helper methods for the Node SDK (which you can see in the AuthKit quick start) which we're now in the process of porting to other languages, including Python.
Thanks for this, it helps knowing which JWT is the most popular in Python world.
Once those helper methods land in the Python SDK I'll let you know in this issue.
Either in this repo, or on the Flask sample, what is the status of AuthKit integration?
I've been manually translating the node examples into Python, here is what I've come up with for the core parts.
I looked into the state of JWT in Python and the most up-to-date library currently is joserfc.
These are snippets for LiteStar framework, but the core parts should be extracted probably into the SDK, so not everyone has to look up the right JWKS validation libraries and methods.
The text was updated successfully, but these errors were encountered: