Skip to content

Commit

Permalink
Make org_name and org_slug optional in Discovery.Organizations.Create (
Browse files Browse the repository at this point in the history
  • Loading branch information
logan-stytch authored Nov 13, 2024
1 parent 99e2c57 commit c8935e1
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 67 deletions.
28 changes: 16 additions & 12 deletions stytch/b2b/api/discovery_organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def __init__(
def create(
self,
intermediate_session_token: str,
organization_name: str,
organization_slug: str,
session_duration_minutes: Optional[int] = None,
session_custom_claims: Optional[Dict[str, Any]] = None,
organization_name: Optional[str] = None,
organization_slug: Optional[str] = None,
organization_logo_url: Optional[str] = None,
trusted_metadata: Optional[Dict[str, Any]] = None,
sso_jit_provisioning: Optional[str] = None,
Expand Down Expand Up @@ -64,8 +64,6 @@ def create(
Fields:
- intermediate_session_token: The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
- organization_name: The name of the Organization. If the name is not specified, a default name will be created based on the email used to initiate the discovery flow. If the email domain is a common email provider such as gmail.com, or if the email is a .edu email, the organization name will be generated based on the name portion of the email. Otherwise, the organization name will be generated based on the email domain.
- organization_slug: The unique URL slug of the Organization. A minimum of two characters is required. The slug only accepts alphanumeric characters and the following reserved characters: `-` `.` `_` `~`. If the slug is not specified, a default slug will be created based on the email used to initiate the discovery flow. If the email domain is a common email provider such as gmail.com, or if the email is a .edu email, the organization slug will be generated based on the name portion of the email. Otherwise, the organization slug will be generated based on the email domain.
- session_duration_minutes: Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
five minutes regardless of the underlying session duration, and will need to be refreshed over time.
Expand All @@ -80,6 +78,8 @@ def create(
`session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To
delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
Total custom claims size cannot exceed four kilobytes.
- organization_name: The name of the Organization. If the name is not specified, a default name will be created based on the email used to initiate the discovery flow. If the email domain is a common email provider such as gmail.com, or if the email is a .edu email, the organization name will be generated based on the name portion of the email. Otherwise, the organization name will be generated based on the email domain.
- organization_slug: The unique URL slug of the Organization. A minimum of two characters is required. The slug only accepts alphanumeric characters and the following reserved characters: `-` `.` `_` `~`. If the slug is not specified, a default slug will be created based on the email used to initiate the discovery flow. If the email domain is a common email provider such as gmail.com, or if the email is a .edu email, the organization slug will be generated based on the name portion of the email. Otherwise, the organization slug will be generated based on the email domain.
- organization_logo_url: The image URL of the Organization logo.
- trusted_metadata: An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
- sso_jit_provisioning: The authentication setting that controls the JIT provisioning of Members when authenticating via SSO. The accepted values are:
Expand Down Expand Up @@ -147,13 +147,15 @@ def create(
headers: Dict[str, str] = {}
data: Dict[str, Any] = {
"intermediate_session_token": intermediate_session_token,
"organization_name": organization_name,
"organization_slug": organization_slug,
}
if session_duration_minutes is not None:
data["session_duration_minutes"] = session_duration_minutes
if session_custom_claims is not None:
data["session_custom_claims"] = session_custom_claims
if organization_name is not None:
data["organization_name"] = organization_name
if organization_slug is not None:
data["organization_slug"] = organization_slug
if organization_logo_url is not None:
data["organization_logo_url"] = organization_logo_url
if trusted_metadata is not None:
Expand Down Expand Up @@ -193,10 +195,10 @@ def create(
async def create_async(
self,
intermediate_session_token: str,
organization_name: str,
organization_slug: str,
session_duration_minutes: Optional[int] = None,
session_custom_claims: Optional[Dict[str, Any]] = None,
organization_name: Optional[str] = None,
organization_slug: Optional[str] = None,
organization_logo_url: Optional[str] = None,
trusted_metadata: Optional[Dict[str, Any]] = None,
sso_jit_provisioning: Optional[str] = None,
Expand Down Expand Up @@ -232,8 +234,6 @@ async def create_async(
Fields:
- intermediate_session_token: The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
- organization_name: The name of the Organization. If the name is not specified, a default name will be created based on the email used to initiate the discovery flow. If the email domain is a common email provider such as gmail.com, or if the email is a .edu email, the organization name will be generated based on the name portion of the email. Otherwise, the organization name will be generated based on the email domain.
- organization_slug: The unique URL slug of the Organization. A minimum of two characters is required. The slug only accepts alphanumeric characters and the following reserved characters: `-` `.` `_` `~`. If the slug is not specified, a default slug will be created based on the email used to initiate the discovery flow. If the email domain is a common email provider such as gmail.com, or if the email is a .edu email, the organization slug will be generated based on the name portion of the email. Otherwise, the organization slug will be generated based on the email domain.
- session_duration_minutes: Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
five minutes regardless of the underlying session duration, and will need to be refreshed over time.
Expand All @@ -248,6 +248,8 @@ async def create_async(
`session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To
delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
Total custom claims size cannot exceed four kilobytes.
- organization_name: The name of the Organization. If the name is not specified, a default name will be created based on the email used to initiate the discovery flow. If the email domain is a common email provider such as gmail.com, or if the email is a .edu email, the organization name will be generated based on the name portion of the email. Otherwise, the organization name will be generated based on the email domain.
- organization_slug: The unique URL slug of the Organization. A minimum of two characters is required. The slug only accepts alphanumeric characters and the following reserved characters: `-` `.` `_` `~`. If the slug is not specified, a default slug will be created based on the email used to initiate the discovery flow. If the email domain is a common email provider such as gmail.com, or if the email is a .edu email, the organization slug will be generated based on the name portion of the email. Otherwise, the organization slug will be generated based on the email domain.
- organization_logo_url: The image URL of the Organization logo.
- trusted_metadata: An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
- sso_jit_provisioning: The authentication setting that controls the JIT provisioning of Members when authenticating via SSO. The accepted values are:
Expand Down Expand Up @@ -315,13 +317,15 @@ async def create_async(
headers: Dict[str, str] = {}
data: Dict[str, Any] = {
"intermediate_session_token": intermediate_session_token,
"organization_name": organization_name,
"organization_slug": organization_slug,
}
if session_duration_minutes is not None:
data["session_duration_minutes"] = session_duration_minutes
if session_custom_claims is not None:
data["session_custom_claims"] = session_custom_claims
if organization_name is not None:
data["organization_name"] = organization_name
if organization_slug is not None:
data["organization_slug"] = organization_slug
if organization_logo_url is not None:
data["organization_logo_url"] = organization_logo_url
if trusted_metadata is not None:
Expand Down
12 changes: 6 additions & 6 deletions stytch/b2b/api/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,9 @@ def update(
if sso_jit_provisioning is not None:
data["sso_jit_provisioning"] = sso_jit_provisioning
if sso_jit_provisioning_allowed_connections is not None:
data["sso_jit_provisioning_allowed_connections"] = (
sso_jit_provisioning_allowed_connections
)
data[
"sso_jit_provisioning_allowed_connections"
] = sso_jit_provisioning_allowed_connections
if email_allowed_domains is not None:
data["email_allowed_domains"] = email_allowed_domains
if email_jit_provisioning is not None:
Expand Down Expand Up @@ -689,9 +689,9 @@ async def update_async(
if sso_jit_provisioning is not None:
data["sso_jit_provisioning"] = sso_jit_provisioning
if sso_jit_provisioning_allowed_connections is not None:
data["sso_jit_provisioning_allowed_connections"] = (
sso_jit_provisioning_allowed_connections
)
data[
"sso_jit_provisioning_allowed_connections"
] = sso_jit_provisioning_allowed_connections
if email_allowed_domains is not None:
data["email_allowed_domains"] = email_allowed_domains
if email_jit_provisioning is not None:
Expand Down
12 changes: 6 additions & 6 deletions stytch/b2b/api/passwords_discovery_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def reset_start(
if reset_password_template_id is not None:
data["reset_password_template_id"] = reset_password_template_id
if reset_password_expiration_minutes is not None:
data["reset_password_expiration_minutes"] = (
reset_password_expiration_minutes
)
data[
"reset_password_expiration_minutes"
] = reset_password_expiration_minutes
if pkce_code_challenge is not None:
data["pkce_code_challenge"] = pkce_code_challenge
if locale is not None:
Expand Down Expand Up @@ -132,9 +132,9 @@ async def reset_start_async(
if reset_password_template_id is not None:
data["reset_password_template_id"] = reset_password_template_id
if reset_password_expiration_minutes is not None:
data["reset_password_expiration_minutes"] = (
reset_password_expiration_minutes
)
data[
"reset_password_expiration_minutes"
] = reset_password_expiration_minutes
if pkce_code_challenge is not None:
data["pkce_code_challenge"] = pkce_code_challenge
if locale is not None:
Expand Down
12 changes: 6 additions & 6 deletions stytch/b2b/api/passwords_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def reset_start(
if reset_password_redirect_url is not None:
data["reset_password_redirect_url"] = reset_password_redirect_url
if reset_password_expiration_minutes is not None:
data["reset_password_expiration_minutes"] = (
reset_password_expiration_minutes
)
data[
"reset_password_expiration_minutes"
] = reset_password_expiration_minutes
if code_challenge is not None:
data["code_challenge"] = code_challenge
if login_redirect_url is not None:
Expand Down Expand Up @@ -138,9 +138,9 @@ async def reset_start_async(
if reset_password_redirect_url is not None:
data["reset_password_redirect_url"] = reset_password_redirect_url
if reset_password_expiration_minutes is not None:
data["reset_password_expiration_minutes"] = (
reset_password_expiration_minutes
)
data[
"reset_password_expiration_minutes"
] = reset_password_expiration_minutes
if code_challenge is not None:
data["code_challenge"] = code_challenge
if login_redirect_url is not None:
Expand Down
Loading

0 comments on commit c8935e1

Please sign in to comment.