Kick off the login process for a user with an OIDC client.
Arguments
oidcClientId string
The OIDC client ID to use for login (use either this or customerId, not both)
customerId string
The customer ID to use for login (use either this or oidcClientId, not both)
postLoginRedirectUrl string
The URL to redirect the user to after they have successfully logged into your app. This is not the same as the redirect URL used when creating the OIDC client.
This value will be returned in the response after successfully completing the OIDC login. It is up to you to handle the redirect yourself.
Must be allowed by your post_login_redirect_origin_allowlist setting.
This value will be returned in the response after successfully completing the OIDC login. It is up to you to handle the redirect yourself.
Must be allowed by your post_login_redirect_origin_allowlist setting.
Successful Response
sendUserToIdpUrl string
The URL to redirect the user to for authentication with their OIDC provider
stateForCookie string
A state value that you should store as a cookie. We'll read this value in the Complete OIDC Login function to protect against CSRF attacks
Error Types
ClientNotFound
The provided oidcClientId or customerId does not match any configured OIDC client
RedirectUrlInvalid
The provided postLoginRedirectUrl is not allowed or invalid
UnexpectedError
An unexpected error occurred during the operation
const auth = createClient({ url, integrationKey });
const result = await auth.sso.initiateOidcLogin({ oidcClientId: "0oaulhbkt9YBiT3Pn697", postLoginRedirectUrl: "https://app.example.com/authorization-code/callback"});
if (result.ok) { console.log("OIDC login initiated successfully"); // Redirect user to result.data.sendUserToIdpUrl // Store result.data.stateForCookie in a cookie res.redirect(result.data.sendUserToIdpUrl);} else { console.log(`Error: ${result.error}`); // Check result.error.type to handle specific errors}client = create_client(url=url, integration_key=integration_key)
result = await client.sso.initiate_oidc_login( oidc_client_id="0oaulhbkt9YBiT3Pn697", post_login_redirect_url="https://app.example.com/authorization-code/callback")
if is_ok(result): print("OIDC login initiated successfully") # Redirect user to result.data.send_user_to_idp_url # Store result.data.state_for_cookie in a cookie return RedirectResponse(url=result.data.send_user_to_idp_url)else: print(f"Error: {result.error}") # Check result.error.type to handle specific errorsclient, err := byo.NewClient(url, integrationKey)if err != nil { log.Fatal(err)}
result, err := client.Sso.InitiateOIDCLogin(ctx, &byo.InitiateOidcLoginCommandOIDCClientID{ OIDCClientID: "0oaulhbkt9YBiT3Pn697", PostLoginRedirectURL: byo.String("https://app.example.com/authorization-code/callback"),})if err != nil { log.Fatal(err)}
// Store result.StateForCookie in a cookie, then// redirect the user to result.SendUserToIdpURLhttp.Redirect(w, r, result.SendUserToIdpURL, http.StatusFound)PropelAuthClient client = PropelAuthClient.create(url, integrationKey);
InitiateOidcLoginCommand command = InitiateOidcLoginCommand.oidcClientId.builder() .oidcClientId("0oaulhbkt9YBiT3Pn697") .postLoginRedirectUrl("https://app.example.com/authorization-code/callback") .build();
try { InitiateOidcLoginResponse response = client.sso.initiateOidcLogin(command); System.out.println("OIDC login initiated successfully"); // Redirect user to response.getSendUserToIdpUrl() // Store response.getStateForCookie() in a cookie} catch (InitiateOidcLoginException.ClientNotFound e) { System.out.println("Error: Client not found");} catch (InitiateOidcLoginException.RedirectUrlInvalid e) { System.out.println("Error: Redirect URL invalid");} catch (InitiateOidcLoginException e) { System.out.println("Error: " + e.getMessage());}var client = new PropelAuthClient(new PropelAuthOptions { Url = url, IntegrationKey = integrationKey });
// You can also use InitiateOidcLoginByCustomerIdAsync(customerId, postLoginRedirectUrl)try{ var response = await client.Sso.InitiateOidcLoginByOidcClientIdAsync( oidcClientId: "0oaulhbkt9YBiT3Pn697", postLoginRedirectUrl: "https://app.example.com/authorization-code/callback" );
Console.WriteLine("OIDC login initiated successfully"); // Redirect user to response.SendUserToIdpUrl // Store response.StateForCookie in a cookie}catch (InitiateOidcLoginException.ClientNotFound){ Console.WriteLine("Error: Client not found");}catch (InitiateOidcLoginException.RedirectUrlInvalid ex){ Console.WriteLine($"Error: Redirect URL invalid - {ex.Details.Message}");}catch (InitiateOidcLoginException ex){ Console.WriteLine($"Error: {ex.Message}");}
Response
{ ok: true, data: { sendUserToIdpUrl: "https://example.okta.com/oauth2/v1...", stateForCookie: "NlTgYMWY2hiRmCV30kEPng" }}Result( data=InitiateOidcLoginResponse( send_user_to_idp_url="https://example.okta.com/oauth2/v1...", state_for_cookie="NlTgYMWY2hiRmCV30kEPng" ))byo.InitiateOidcLoginResponse{ SendUserToIdpURL: "https://example.okta.com/oauth2/v1...", StateForCookie: "NlTgYMWY2hiRmCV30kEPng",}InitiateOidcLoginResponse( sendUserToIdpUrl="https://example.okta.com/oauth2/v1...", stateForCookie="NlTgYMWY2hiRmCV30kEPng")InitiateOidcLoginResponse{ SendUserToIdpUrl = "https://example.okta.com/oauth2/v1...", StateForCookie = "NlTgYMWY2hiRmCV30kEPng"}