Keycloak Okta Identity Provider: OIDC Setup
Add Okta as an identity provider in Keycloak using the generic OIDC provider. Covers Okta OIDC app creation, authorization server selection, Keycloak IDP configuration, attribute mappers, and first login flow.
KeycloakPro Team
KeycloakPro Team
Introduction
Adding Okta as an identity provider in Keycloak lets users sign in with their Okta credentials. Keycloak acts as the OIDC relying party — it redirects users to Okta for authentication and receives back a user identity it can map to a local account.
Keycloak doesn't have a built-in Okta provider type, so you use the generic OpenID Connect v1.0 provider with Okta's authorization server discovery URL. The setup takes about 15 minutes.
How identity brokering works
The login flow goes: user clicks "Sign in with Okta" → Keycloak redirects to Okta → user authenticates → Okta sends an authorization code to Keycloak's broker endpoint → Keycloak exchanges it for tokens → Keycloak creates or links the user → user lands in your application.
The redirect URI you register in Okta is:
https://keycloak.example.com/realms/YOUR_REALM/broker/okta/endpoint
The alias okta in the URL matches the alias you set when creating the identity provider in Keycloak.
Prerequisites
- Keycloak 24+ running on HTTPS
- A Keycloak realm with admin access
- An Okta account with admin access — Developer Edition works
Step 1 — Create an OIDC application in Okta
In the Okta Admin Console:
- Applications → Applications → Create App Integration
- Sign-in method: OIDC — OpenID Connect
- Application type: Web Application
- Click Next

App settings:
- App integration name:
keycloak - Sign-in redirect URIs:
https://keycloak.example.com/realms/YOUR_REALM/broker/okta/endpoint - Sign-out redirect URIs: optional — add
https://keycloak.example.com/realms/YOUR_REALM/protocol/openid-connect/logoutif you want back-channel logout coordination - Assignments: Limit access to selected groups (recommended) or Allow everyone in your organization
Click Save.

Step 2 — Copy the Client ID and Client Secret
After saving, the app settings page shows:
- Client ID — always visible
- Client secret — click Show to reveal, then copy

Note your Okta domain (shown in the top-right of the admin console): YOUR_DOMAIN.okta.com. This goes into the discovery URL.
Step 3 — Choose an authorization server
Okta has two types of authorization servers:
- Org Authorization Server —
https://YOUR_DOMAIN.okta.com— issues tokens that contain Okta user profile claims. Available on all plans. - Custom Authorization Servers —
https://YOUR_DOMAIN.okta.com/oauth2/SERVER_ID— thedefaultserver ishttps://YOUR_DOMAIN.okta.com/oauth2/default. More configurable, supports custom claims.
For most setups, use the default custom authorization server. The discovery URL for it is:
https://YOUR_DOMAIN.okta.com/oauth2/default/.well-known/openid-configuration
If you have a specific custom authorization server, replace default with its ID.
Step 4 — Configure the Identity Provider in Keycloak
In the Keycloak admin console:
- Select your realm
- Identity Providers → Add provider → OpenID Connect v1.0
- Alias:
okta - Display name:
Okta - Discovery Endpoint:
https://YOUR_DOMAIN.okta.com/oauth2/default/.well-known/openid-configuration - Client ID: paste from Step 2
- Client Secret: paste from Step 2
- Default Scopes:
openid profile email
Click Add.

Step 5 — Configure attribute mappers
The Okta default authorization server issues these claims:
| Okta claim | Description |
|---|---|
sub | Unique Okta user ID |
preferred_username | Okta login (usually email) |
name | Display name |
given_name | First name |
family_name | Last name |
email | Email address |
groups | Group memberships (if configured in the authorization server) |
Keycloak's generic OIDC provider doesn't add default mappers. Add them:
- Identity Providers → okta → Mappers → Add mapper
Email mapper:
- Mapper type: Attribute Importer
- Name:
email - Claim:
email - User Attribute Name:
email
First name mapper:
- Mapper type: Attribute Importer
- Name:
firstName - Claim:
given_name - User Attribute Name:
firstName
Last name mapper:
- Mapper type: Attribute Importer
- Name:
lastName - Claim:
family_name - User Attribute Name:
lastName

5.1 — Optional: map Okta groups
If you need Okta group memberships in Keycloak, configure the Okta authorization server to include a groups claim, then add a mapper in Keycloak.
In Okta:
- Security → API → Authorization Servers → default → Claims → Add Claim
- Name:
groups - Include in token type: ID Token → Always
- Value type: Groups
- Filter: Matches regex
.*(all groups) or a specific group name pattern - Include in: Any scope
In Keycloak, after saving the IDP:
- Mappers → Add mapper
- Mapper type: Hardcoded Role (to grant a role) or create a custom mapper via Advanced Claim to Group (if available) or use a script mapper for group-based RBAC
The exact approach depends on how your Keycloak RBAC is structured. For simple role assignment based on an Okta group, the Hardcoded Role mapper is the quickest path.

Step 6 — Configure the First Login Flow
In Identity Providers → okta → Settings → First Login Flow, the default first broker login flow handles new users on their first Okta login to Keycloak.
Set Sync Mode:
import— copy attributes from Okta on first login onlyforce— overwrite Keycloak attributes from Okta on every login
Use force if Okta is the authoritative directory for user attributes.

Step 7 — Test the login
Open a private browser window and go to your Keycloak realm login page. An Okta button appears.

After completing Okta's login flow, Keycloak creates or links the user. Confirm: Keycloak admin → Users → find the user → Identity Provider Links tab. The external user ID is the Okta sub value.

Troubleshooting common issues
"The authorization server is not found" on Okta's login page
The discovery URL doesn't point to an existing authorization server. Check that YOUR_DOMAIN.okta.com is correct and that the authorization server name (default or your custom server ID) is right. Open the discovery URL in a browser to confirm it returns JSON.
"error: invalid_client" during token exchange
The client secret is wrong. Okta auto-generates a new client secret when you click Rotate in the app settings. Copy the current secret and update it in Keycloak. The client ID doesn't change when the secret rotates.
Users get "You do not have permission to access this app"
The Okta app's Assignments settings restrict access. The user trying to log in isn't assigned to the app individually or via a group. Go to the app's Assignments tab and add the user or their group.
Attribute mappers show blank values after login
Decode the ID token at jwt.io to see exactly which claims Okta is sending. If given_name and family_name are missing, the user's Okta profile may not have these fields set, or the Okta authorization server's profile scope doesn't include them. You can add custom claims in the Okta authorization server to include specific profile attributes.
Login works but groups are missing from the token
Check that the groups claim was added to the Okta authorization server (Step 5.1) and that it includes ID Token. Groups claims don't appear unless the claim is configured to include them. After adding the claim, log in again — Keycloak caches tokens per session.
"discovery_document_error" in Keycloak logs
Keycloak can't fetch the discovery document during the login flow. Check that Keycloak's server can reach Okta's domain on port 443 (outbound HTTPS). Also verify there's no proxy blocking the connection.
Production checklist
- App assignments configured — avoid "Allow everyone" unless that's the intent
- Client secret stored outside source control
- Authorization server chosen deliberately: org server vs custom
defaultserver - Attribute mappers configured for email, firstName, lastName
- Groups claim configured in Okta if group-based RBAC is needed
- Discovery URL verified by opening in browser before configuring Keycloak
- Sync Mode chosen deliberately
- Client secret rotation process documented — Okta doesn't auto-rotate secrets
Need help integrating Okta with Keycloak?
We deliver production-ready Okta + Keycloak integrations in 1–3 weeks.
Fixed-price, zero vendor lock-in, full source code ownership.