Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds session helpers #384

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Adds session helpers #384

wants to merge 15 commits into from

Conversation

PaulAsjes
Copy link
Contributor

@PaulAsjes PaulAsjes commented Nov 22, 2024

Fixes #350

Description

Adds new session helpers. Example API:

# Load session
session = workos.user_management.load_sealed_session(session_data=request.cookies.get('wos_session'), cookie_password=cookie_password)

# Authenticate user
response = session.authenticate()

current_user = response.user if response.authenticated else None

# Refresh session
result = session.refresh()
if result.authenticated == False:
    print("Refresh failed)

# Get log out URL
url = session.get_logout_url()

Also makes it so dependencies are loaded from requirements.txt rather than hardcoded in setup.py.

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@PaulAsjes PaulAsjes requested a review from a team as a code owner November 22, 2024 14:20
@PaulAsjes PaulAsjes assigned PaulAsjes and unassigned PaulAsjes Nov 22, 2024
Copy link
Contributor

@mattgd mattgd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding! Left a bunch of comments inline, but most are minor.

requirements.txt Show resolved Hide resolved
workos/session.py Outdated Show resolved Hide resolved
workos/session.py Outdated Show resolved Hide resolved
workos/session.py Outdated Show resolved Hide resolved
workos/types/user_management/session.py Outdated Show resolved Hide resolved
workos/user_management.py Outdated Show resolved Hide resolved
workos/user_management.py Outdated Show resolved Hide resolved
workos/session.py Outdated Show resolved Hide resolved
workos/session.py Outdated Show resolved Hide resolved
workos/session.py Outdated Show resolved Hide resolved
Copy link
Contributor

@mattgd mattgd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! There's still two outstanding comments regarding List vs. Sequence in /types/user_management/session.py, but nothing new from second pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Status of AuthKit
2 participants