Skip to content
Open
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
728533c
test: add failing tests for python sdk error hierarchy and base model
ejirocodes Mar 24, 2026
a8c18f3
feat: add python sdk package skeleton with error hierarchy
ejirocodes Mar 24, 2026
fbe1c5b
test: add failing tests for sync and async HTTP client
ejirocodes Mar 24, 2026
6b4cd35
test: add failing tests for jwt verification and jwks fetching
ejirocodes Mar 24, 2026
488e72a
feat: add user, team, session, contact channel, and permission pydant…
ejirocodes Mar 24, 2026
7b75ba8
feat: add jwt verification with async jwks fetcher and ttl cache
ejirocodes Mar 24, 2026
28171d4
feat: add sync and async HTTP client with retry logic
ejirocodes Mar 24, 2026
aecd4aa
feat: add project, api key, oauth, payment, and notification models
ejirocodes Mar 24, 2026
07c32d4
feat: add pagination support with cursor-based PaginatedResult
ejirocodes Mar 24, 2026
ea427ed
test: add failing tests for auth module
ejirocodes Mar 24, 2026
ad63cf0
test: add failing tests for token store subsystem
ejirocodes Mar 24, 2026
3ca5501
feat: add authenticate_request with jwt verification and partial decode
ejirocodes Mar 24, 2026
8060bc6
feat: export auth types and functions from stack_auth package
ejirocodes Mar 24, 2026
6b11389
feat: add token store with CAS-based refresh and dual locks
ejirocodes Mar 24, 2026
13f8875
test: add failing tests for StackServerApp and AsyncStackServerApp
ejirocodes Mar 25, 2026
fd3a816
feat: add StackServerApp and AsyncStackServerApp with user CRUD
ejirocodes Mar 25, 2026
7eb0c25
feat: export StackServerApp and AsyncStackServerApp from package root
ejirocodes Mar 25, 2026
e1ccb71
test: add failing tests for session management methods
ejirocodes Mar 25, 2026
7f4e3eb
feat: add session management methods to StackServerApp and AsyncStack…
ejirocodes Mar 25, 2026
3094338
test: add failing tests for team CRUD methods
ejirocodes Mar 25, 2026
3bf752f
feat: add team CRUD and API key lookup to StackServerApp
ejirocodes Mar 25, 2026
c48b9ca
test: add failing tests for team membership, invitations, and profiles
ejirocodes Mar 25, 2026
cd64ecb
feat: add team membership, invitations, and member profiles
ejirocodes Mar 25, 2026
6b012c0
test: add failing tests for permission management methods
ejirocodes Mar 25, 2026
e26f3a2
feat: add permission management methods to StackServerApp
ejirocodes Mar 25, 2026
c2f3a3a
test: add failing tests for contact channel verification methods
ejirocodes Mar 25, 2026
adeb156
feat: add contact channel verification methods to StackServerApp
ejirocodes Mar 25, 2026
7e41fc8
feat: add api key management methods to both facades
ejirocodes Mar 25, 2026
eae4842
feat: add oauth provider methods and connected accounts to both facades
ejirocodes Mar 25, 2026
e8ce41b
fix: update team member profile test to include required user_id field
ejirocodes Mar 25, 2026
0e6afdc
feat: add ServerItem, AsyncServerItem, and EmailDeliveryInfo models
ejirocodes Mar 25, 2026
c5ab839
feat: add payment methods and email sending to StackServerApp
ejirocodes Mar 25, 2026
299718c
feat: add data vault store with key-value operations
ejirocodes Mar 25, 2026
23c9f85
feat: add get_data_vault_store to facade classes and exports
ejirocodes Mar 25, 2026
f3780f2
docs: add comprehensive Google-style docstrings to all public SDK met…
ejirocodes Mar 25, 2026
c4ee7da
docs: add module docstring with quick-start example and complete PyPI…
ejirocodes Mar 25, 2026
1343d3a
test: add integration tests for payment, email, and data vault methods
ejirocodes Mar 25, 2026
0f39d10
fix: make metadata fields nullable on user and team models
ejirocodes Mar 25, 2026
c6da1ff
Merge branch 'stack-auth:dev' into feat/python-sdk
ejirocodes Mar 25, 2026
287183b
Merge branch 'feat/python-sdk' of https://github.com/ejirocodes/stack…
ejirocodes Mar 25, 2026
6138ff0
test: add failing tests for publishable_client_key and token store de…
ejirocodes Mar 25, 2026
0959548
fix: add publishable_client_key parameter and fix token store defaults
ejirocodes Mar 25, 2026
80f2c32
test: add failing tests for get_partial_user method
ejirocodes Mar 25, 2026
6c0c58d
feat: add get_partial_user method to StackServerApp and AsyncStackSer…
ejirocodes Mar 25, 2026
bfff27d
fix: make RequestLike runtime_checkable and remove type: ignore from …
ejirocodes Mar 25, 2026
7ec2e27
fix: add debug logging to authenticate_request exception handlers
ejirocodes Mar 25, 2026
b7e21a0
fix: replace broad exception catches with specific types and add debu…
ejirocodes Mar 25, 2026
625e3c0
test: add end-to-end integration test suite for live Stack Auth valid…
ejirocodes Mar 25, 2026
9ddc8aa
docs: add comprehensive README for python sdk
ejirocodes Mar 25, 2026
5c09ea7
Merge branch 'stack-auth:dev' into feat/python-sdk
ejirocodes Mar 26, 2026
d055007
fix: address PR review findings from bot analysis
ejirocodes Mar 26, 2026
5cbad57
fix: catch NotFoundError in data vault delete to match spec contract
ejirocodes Mar 26, 2026
37118e0
fix: skip aud/iss verification when not provided and narrow data vaul…
ejirocodes Mar 26, 2026
cac86ef
fix: add None guard before model_validate in get_item methods
ejirocodes Mar 26, 2026
131bb89
docs: clarify why 429 retries apply to all HTTP methods
ejirocodes Mar 26, 2026
e9105b3
fix: harden response parsing and add missing None guards
ejirocodes Mar 26, 2026
f7786c3
docs: add missing docstrings to reach 80% coverage threshold
ejirocodes Mar 26, 2026
b44fabc
fix: validate mutually exclusive product_id/product in grant_product
ejirocodes Mar 26, 2026
6aaa4b3
fix: guard against non-dict JSON in token refresh response
ejirocodes Mar 26, 2026
9aeed6b
fix: map TEAM_MEMBERSHIP_NOT_FOUND to NotFoundError
ejirocodes Mar 26, 2026
a6ac188
refactor: use modern Python 3.10+ imports in token store module
ejirocodes Mar 26, 2026
94293c1
fix: raise RateLimitError when 429 retries are exhausted
ejirocodes Mar 26, 2026
573fe23
fix: treat missing access_token in refresh response as failure
ejirocodes Mar 26, 2026
a26a682
refactor: extract _get_actual_status helper to deduplicate header par…
ejirocodes Mar 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add contact channel verification methods to StackServerApp
- list_contact_channels, create_contact_channel for user channels
- send_verification_code with optional callback URL
- verify_contact_channel to validate codes
- Both sync and async facades
  • Loading branch information
ejirocodes committed Mar 25, 2026
commit adeb156d1aca2dda897c7f827f57e6c8578a3abe
143 changes: 143 additions & 0 deletions sdks/implementations/python/src/stack_auth/_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from stack_auth._pagination import PaginatedResult, _PaginationMeta
from stack_auth._token_store import TokenStore, TokenStoreInit, resolve_token_store
from stack_auth.errors import ApiKeyError, NotFoundError
from stack_auth.models.contact_channels import ContactChannel
from stack_auth.models.permissions import TeamPermission
from stack_auth.models.sessions import ActiveSession
from stack_auth.models.teams import ServerTeam, TeamInvitation, TeamMemberProfile
Expand Down Expand Up @@ -531,6 +532,90 @@ def get_permission(
return None
return TeamPermission.model_validate(items[0])

# -- contact channels ----------------------------------------------------

def list_contact_channels(self, user_id: str) -> list[ContactChannel]:
"""List contact channels for a user.

Args:
user_id: The user whose contact channels to list.

Returns:
A list of :class:`ContactChannel` objects.
"""
data = self._client.request(
"GET", "/contact-channels", params={"user_id": user_id}
)
return [
ContactChannel.model_validate(item)
for item in (data or {}).get("items", [])
]

def create_contact_channel(
self,
user_id: str,
*,
value: str,
type: str = "email",
used_for_auth: bool,
is_primary: Optional[bool] = None,
is_verified: Optional[bool] = None,
) -> ContactChannel:
"""Create a new contact channel for a user.

Args:
user_id: The user to create the channel for.
value: The channel value (e.g., email address).
type: The channel type (default: ``"email"``).
used_for_auth: Whether this channel is used for authentication.
is_primary: Whether this is the primary channel.
is_verified: Whether the channel is pre-verified.

Returns:
The created :class:`ContactChannel`.
"""
body = _build_params(
user_id=user_id,
value=value,
type=type,
used_for_auth=used_for_auth,
is_primary=is_primary,
is_verified=is_verified,
)
data = self._client.request(
"POST", "/contact-channels", body=body
)
return ContactChannel.model_validate(data)

def send_verification_code(
self,
contact_channel_id: str,
*,
callback_url: Optional[str] = None,
) -> None:
"""Send a verification email for a contact channel.

Args:
contact_channel_id: The channel to send verification for.
callback_url: Optional URL to redirect after verification.
"""
body = _build_params(callback_url=callback_url)
self._client.request(
"POST",
f"/contact-channels/{contact_channel_id}/send-verification-email",
body=body,
)

def verify_contact_channel(self, code: str) -> None:
"""Verify a contact channel with a verification code.

Args:
code: The verification code received via email.
"""
self._client.request(
"POST", "/contact-channels/verify", body={"code": code}
)


# ---------------------------------------------------------------------------
# AsyncStackServerApp (async)
Expand Down Expand Up @@ -998,3 +1083,61 @@ async def get_permission(
if not items:
return None
return TeamPermission.model_validate(items[0])

# -- contact channels ----------------------------------------------------

async def list_contact_channels(
self, user_id: str
) -> list[ContactChannel]:
"""List contact channels for a user."""
data = await self._client.request(
"GET", "/contact-channels", params={"user_id": user_id}
)
return [
ContactChannel.model_validate(item)
for item in (data or {}).get("items", [])
]

async def create_contact_channel(
self,
user_id: str,
*,
value: str,
type: str = "email",
used_for_auth: bool,
is_primary: Optional[bool] = None,
is_verified: Optional[bool] = None,
) -> ContactChannel:
"""Create a new contact channel for a user."""
body = _build_params(
user_id=user_id,
value=value,
type=type,
used_for_auth=used_for_auth,
is_primary=is_primary,
is_verified=is_verified,
)
data = await self._client.request(
"POST", "/contact-channels", body=body
)
return ContactChannel.model_validate(data)

async def send_verification_code(
self,
contact_channel_id: str,
*,
callback_url: Optional[str] = None,
) -> None:
"""Send a verification email for a contact channel."""
body = _build_params(callback_url=callback_url)
await self._client.request(
"POST",
f"/contact-channels/{contact_channel_id}/send-verification-email",
body=body,
)

async def verify_contact_channel(self, code: str) -> None:
"""Verify a contact channel with a verification code."""
await self._client.request(
"POST", "/contact-channels/verify", body={"code": code}
)