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
@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:codeand:code_verifier
@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.