Skip to content

Comments

feat: add selectedTenant to AccessKeyLoginOptions#768

Merged
aviadl merged 2 commits intodescope:mainfrom
itamartal:itamar-tenzai/add-selected-tenant-to-key-exchange
Feb 23, 2026
Merged

feat: add selectedTenant to AccessKeyLoginOptions#768
aviadl merged 2 commits intodescope:mainfrom
itamartal:itamar-tenzai/add-selected-tenant-to-key-exchange

Conversation

@itamartal
Copy link
Contributor

Summary

The AccessKeyLoginOptions in the Python SDK is missing the selectedTenant field, which is already supported by the Descope API and by other SDKs such as the Go SDK:

type AccessKeyLoginOptions struct {
	CustomClaims   map[string]any `json:"customClaims,omitempty"`
	SelectedTenant string         `json:"selectedTenant,omitempty"`
}

Without this field, users who need to exchange an access key with a specific tenant context (to get the dct claim set in the resulting JWT) must bypass the SDK and call the /v1/auth/accesskey/exchange REST API directly, manually constructing the request with the selectedTenant in loginOptions.

Changes

  1. descope/common.py — Added selected_tenant parameter to AccessKeyLoginOptions, serialized as selectedTenant to match the API contract.

  2. descope/auth.py — Updated exchange_access_key to filter out None values from the loginOptions dict, matching the Go SDK's omitempty behavior. This ensures selectedTenant is only included in the request when explicitly provided.

  3. tests/test_auth.py — Added test case verifying that selected_tenant is correctly serialized as selectedTenant in the API request body.

Usage

from descope import AccessKeyLoginOptions

loc = AccessKeyLoginOptions(custom_claims={"k1": "v1"}, selected_tenant="my-tenant-id")
jwt_response = descope_client.exchange_access_key(access_key=key, login_options=loc)

@aviadl aviadl enabled auto-merge (squash) February 23, 2026 12:35
@omercnet omercnet disabled auto-merge February 23, 2026 12:50
@aviadl aviadl merged commit 0f60183 into descope:main Feb 23, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants