The Create OIDC Connection method wraps the Create OIDC Connection API endpoint. The organization_id will be automatically inferred from the logged-in Member's session. This method cannot be used to create OIDC connections in other Organizations.
Create OIDC Connection
Method parameters
A human-readable display name for the connection.
Name of the IdP. Enum with possible values: classlink, cyberark, duo, google-workspace, jumpcloud, keycloak, miniorange, microsoft-entra, okta, onelogin, pingfederate, rippling, salesforce, shibboleth, or generic.
Specifying a known provider allows Stytch to handle any provider-specific logic.
Response fields
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
The OIDC Connection object affected by this API call. See the OIDC Connection Object for complete response field details.
import { useStytchB2BClient } from '@stytch/react/b2b';
export const CreateOIDCConnection = () => {
const stytch = useStytchB2BClient();
const createOIDCConnection = () => {
stytch.sso.oidc.createConnection({
display_name: 'Example OIDC connection',
});
};
return <button onClick={createOIDCConnection}>Create an OIDC Connection</button>;
};
{
"connection": {
"organization_id": "organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931",
"connection_id": "oidc-connection-test-b6c714c2-7413-4b92-a0f1-97aa1085aeff",
"display_name": "Example OIDC Connection",
"redirect_url": "https://test.stytch.com/v1/b2b/sso/callback/oidc-connection-test-b6c714c2-7413-4b92-a0f1-97aa1085aeff",
"status": "active",
"issuer": "https://idp.example.com/",
"client_id": "s6BhdRkqt3",
"client_secret": "SeiGwdj5lKkrEVgcEY3QNJXt6srxS3IK2Nwkar6mXD4=",
"authorization_url": "https://idp.example.com/authorize",
"token_url": "https://idp.example.com/oauth2/token",
"userinfo_url": "https://idp.example.com/userinfo",
"jwks_url": "https://idp.example.com/oauth2/jwks",
"identity_provider": "generic"
},
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"status_code": 200
}
{
"status_code": 401,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "unauthorized_credentials",
"error_message": "Unauthorized credentials.",
"error_url": "https://stytch.com/docs/api/errors/401"
}
{
"status_code": 403,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "session_authorization_error",
"error_message": "The Member is not authorized to perform the requested action on that resource.",
"error_url": "https://stytch.com/docs/api/errors/403"
}
{
"status_code": 429,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "too_many_requests",
"error_message": "Too many requests have been made.",
"error_url": "https://stytch.com/docs/api/errors/429"
}
{
"status_code": 500,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "internal_server_error",
"error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
"error_url": "https://stytch.com/docs/api/errors/500"
}