Arguments
The OIDC client ID to use for login (use either this or customerId, not both)
The customer ID to use for login (use either this or oidcClientId, not both)
The URL to redirect to after successful login. Must be allowed by your post_login_redirect_origin_allowlist setting
Successful Response
The URL to redirect the user to for authentication with their OIDC provider
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
The provided oidcClientId or customerId does not match any configured OIDC client
The provided postLoginRedirectUrl is not allowed or invalid
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 errorsPropelAuthClient 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}");}{ 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" ))InitiateOidcLoginResponse( sendUserToIdpUrl="https://example.okta.com/oauth2/v1...", stateForCookie="NlTgYMWY2hiRmCV30kEPng")InitiateOidcLoginResponse{ SendUserToIdpUrl = "https://example.okta.com/oauth2/v1...", StateForCookie = "NlTgYMWY2hiRmCV30kEPng"}