Validate
5-Line Core
result = await gateway.validate_session(
access_token=token.access_token,
organization_id="default",
)
user = result.unwrap()Step-by-Step
1
# Typically from Authorization header
authorization = request.headers.get("Authorization")
if authorization and authorization.startswith("Bearer "):
access_token = authorization.removeprefix("Bearer ")2
result = await gateway.validate_session(
access_token=access_token,
organization_id="default",
)3
if result.is_ok:
user = result.value
print(f"Token valid! User: {user.email}")
else:
print(f"Token invalid: {result.error.code}")4
Token valid! User: alice@example.comComplete Example
FastAPI Integration
Common Pitfalls
Pitfall
Solution
Next Steps
Last updated
Was this helpful?