This section provides detailed documentation on setting up and using Okta Single Sign-On (SSO) in your project. By following these steps, you will be able to authenticate users using Okta and retrieve their user information.
Before you begin, ensure you have the following environment variables set up in your .env
file:
OKTA_CLIENT_ID
: Okta OAuth client IDOKTA_CLIENT_SECRET
: Okta OAuth client secretOKTA_DOMAIN
: Okta domain (e.g., dev-123456.okta.com)
Ensure that your Okta OAuth application has the following scopes enabled:
openid
profile
email
- Log in to your Okta Developer account at developer.okta.com.
- From the dashboard, navigate to Applications -> Applications.
- Click on Create App Integration.
- Select OAuth 2.0 / OIDC, then click Next.
- Choose Web Application and configure the following settings:
- Sign-in redirect URIs: Add the callback URI of your application (e.g.,
http://localhost:8000/callback
) - Sign-out redirect URIs: Optionally, add a sign-out URI.
- Sign-in redirect URIs: Add the callback URI of your application (e.g.,
- Click Save.
-
After saving the application, you will be redirected to the application settings page.
-
Scroll down to the Client Credentials section.
-
Copy the Client ID and Client Secret and add them to your
.env
file:OKTA_CLIENT_ID=your_client_id OKTA_CLIENT_SECRET=your_client_secret
-
In the Okta dashboard, navigate to Settings -> Customizations -> Domain.
-
Copy your Okta domain (e.g.,
dev-123456.okta.com
) and add it to your.env
file:OKTA_DOMAIN=your_okta_domain