Skip to content

feat: add selectedTenant to AccessKeyLoginOptions#768

Open
itamartal wants to merge 1 commit intodescope:mainfrom
itamartal:itamar-tenzai/add-selected-tenant-to-key-exchange
Open

feat: add selectedTenant to AccessKeyLoginOptions#768
itamartal wants to merge 1 commit intodescope:mainfrom
itamartal:itamar-tenzai/add-selected-tenant-to-key-exchange

Conversation

@itamartal
Copy link

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)

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.

1 participant

Comments