WorkOS.SSO.PKCE (WorkOS SDK for Elixir v3.0.1)

Copy Markdown View Source

PKCE helpers for the SSO authorization-code flow (public clients).

%{url: url, code_verifier: verifier, state: state} =
  WorkOS.SSO.PKCE.get_authorization_url(client, %{redirect_uri: "..."})

# after the redirect comes back with a code:
{:ok, token} =
  WorkOS.SSO.PKCE.code_exchange(client, %{code: code, code_verifier: verifier})

Summary

Functions

Exchanges an SSO authorization code using a PKCE code verifier (public-client flow).

Builds an SSO authorization URL with automatically generated PKCE parameters, plus a random state unless one is passed in params.

Functions

code_exchange(client, params, opts \\ [])

@spec code_exchange(WorkOS.Client.t(), map(), keyword()) ::
  {:ok, WorkOS.SSOTokenResponse.t()} | {:error, WorkOS.Error.error()}

Exchanges an SSO authorization code using a PKCE code verifier (public-client flow).

Parameters

  • params — map with :code and :code_verifier

get_authorization_url(client, params \\ %{})

@spec get_authorization_url(WorkOS.Client.t(), map()) ::
  WorkOS.AuthKit.pkce_authorization_url()

Builds an SSO authorization URL with automatically generated PKCE parameters, plus a random state unless one is passed in params.

Store code_verifier securely — it is required for the token exchange. See WorkOS.SSO.get_authorization_url/2 for the supported params.