Discovery

interface Discovery

The Discovery interface provides methods for discovering a member's available organizations, creating organizations, and exchanging sessions between organizations. The Discovery product lets End Users discover and log in to Organizations they are a Member of, invited to, or eligible to join.

Unlike our other B2B products, Discovery allows End Users to authenticate without specifying an Organization in advance. This is done via a Discovery Magic Link flow. After an End User is authenticated, an Intermediate Session is returned along with a list of associated Organizations.

The End User can then authenticate to the desired Organization by passing the Intermediate Session and organization_id. End users can even create a new Organization instead of joining or logging in to an existing one.

Call the StytchB2BClient.discovery.organizations() method to find a member's available organizations.

Call the StytchB2BClient.discovery.exchangeSession() method to exchange a session between organizations.

Call the StytchB2BClient.discovery.create() method to create a new organization.

Types

Link copied to clipboard
data class CreateOrganizationParameters(    val intermediateSessionToken: String,     val organizationName: String? = null,     val organizationSlug: String? = null,     val organizationLogoUrl: String? = null,     val sessionDurationMinutes: UInt = Constants.DEFAULT_SESSION_TIME_MINUTES,     val ssoJitProvisioning: SsoJitProvisioning? = null,     val emailAllowedDomains: List<String>? = null,     val emailJitProvisioning: EmailJitProvisioning? = null,     val emailInvites: EmailInvites? = null,     val authMethods: AuthMethods? = null,     val allowedAuthMethods: List<AllowedAuthMethods>? = null)

A data class used for wrapping parameters used with creating organizations

Link copied to clipboard
data class DiscoverOrganizationsParameters(val intermediateSessionToken: String? = null)

Data class used for wrapping parameters used with Discovering organizations

Link copied to clipboard
data class SessionExchangeParameters(    val intermediateSessionToken: String,     val organizationId: String,     val sessionDurationMinutes: UInt = Constants.DEFAULT_SESSION_TIME_MINUTES)

Data class used for wrapping parameters used with exchanging sessions between organizations.

Functions

Link copied to clipboard
abstract suspend fun createOrganization(parameters: Discovery.CreateOrganizationParameters): OrganizationCreateResponse
abstract fun createOrganization(parameters: Discovery.CreateOrganizationParameters, callback: (OrganizationCreateResponse) -> Unit)

Create a new organization. If an end user does not want to join any already-existing organization, or has no possible organizations to join, this endpoint can be used to create a new Organization and Member. This operation consumes the Intermediate Session. This endpoint can also be used to start an initial session for the newly created member and organization.

Link copied to clipboard
abstract fun exchangeIntermediateSession(parameters: Discovery.SessionExchangeParameters, callback: (IntermediateSessionExchangeResponse) -> Unit)

Exchange an Intermediate Session for a fully realized Member Session in a desired Organization. This operation consumes the Intermediate Session. This endpoint can be used to accept invites and create new members via domain matching.

Link copied to clipboard
abstract suspend fun listOrganizations(parameters: Discovery.DiscoverOrganizationsParameters): DiscoverOrganizationsResponse
abstract fun listOrganizations(parameters: Discovery.DiscoverOrganizationsParameters, callback: (DiscoverOrganizationsResponse) -> Unit)

Discover a member's available organizations