View Source WorkOS.SSO (WorkOS SDK for Elixir v0.2.0)

The SSO module provides convenience methods for working with the WorkOS SSO platform. You'll need a valid API key, a client ID, and to have created an SSO connection on your WorkOS dashboard.

@see https://docs.workos.com/sso/overview

Link to this section Summary

Functions

Generate an Oauth2 authorization URL where your users will authenticate using the configured SSO Identity Provider.

Fetch the user profile details with an access token.

Fetch the user profile details and access token for the authenticated SSO user using the code passed to your Redirect URI.

Link to this section Functions

Link to this function

delete_connection(connection, opts \\ [])

View Source

Delete a connection

parameters

Parameters

  • connection (string) the ID of the connection to delete

example

Example

WorkOS.SSO.delete_connection("conn_12345")

Link to this function

get_authorization_url(params, opts \\ [])

View Source

Generate an Oauth2 authorization URL where your users will authenticate using the configured SSO Identity Provider.

parameters

Parameters

  • params (map)
    • domain (string) The domain for the relevant SSO Connection configured on your WorkOS dashboard. One of provider, domain, connection, or organization is required. The domain is deprecated.
    • provider (string) A provider name for an Identity Provider configured on your WorkOS dashboard. Only 'GoogleOAuth' and 'MicrosoftOAuth' are supported.
    • connection (string) Unique identifier for a WorkOS Connection
    • organization (string) Unique identifier for a WorkOS Organization
    • client_id (string) Client ID for a WorkOS Environment. This value can be found in the WorkOS dashboard.
    • redirect_uri (string) The URI where users are directed after completing the authentication step. Must match a configured redirect URI on your WorkOS dashboard.
    • state (string) An aribtrary state object that is preserved and available to the client in the response.
    • domain_hint (string) Used to pre-fill domain field when authenticating with MicrosoftOAuth
    • login_hint (string) Used to prefill the username/email field when authenticating with GoogleOAuth or OpenID Connect

example

Example

WorkOS.SSO.get_authorization_url(%{ connection: "conn_123", client_id: "project_01DG5TGK363GRVXP3ZS40WNGEZ", redirect_uri: "https://workos.com/callback" })

Link to this function

get_connection(connection, opts \\ [])

View Source

Get a connection

parameters

Parameters

  • connection (string) The ID of the connection to retrieve

example

Example

WorkOS.SSO.get_connection(connection="conn_123")

Link to this function

get_profile(access_token, opts \\ [])

View Source

Fetch the user profile details with an access token.

parameters

Parameters

  • access_token (string) An access token that can be exchanged for a user profile

example

Example

WorkOS.SSO.get_profile("12345")

Link to this function

get_profile_and_token(code, opts \\ [])

View Source

Fetch the user profile details and access token for the authenticated SSO user using the code passed to your Redirect URI.

parameters

Parameters

  • code (string) The authorization code provided in the callback URL

example

Example

WorkOS.SSO.get_profile_and_token("12345")

Link to this function

list_connections(params \\ %{}, opts \\ [])

View Source

List connections

parameters

Parameters

  • params (map)
    • connection_type (string - optional) Authentication service provider descriptor
    • domain (string - optional) The domain of the connection to be retrieved
    • organization_id (string - optional) The id of the organization of the connections to be retrieved
    • limit (number - optional) Upper limit on the number of objects to return, between 1 and 100. The default value is 10
    • before (string - optional) An object ID that defines your place in the list
    • after (string - optional) An object ID that defines your place in the list
    • order ("asc" or "desc" - optional) Supported values are "asc" and "desc" for ascending and descending order respectively

example

Example

WorkOS.SSO.list_connections()