Various OIDC and OAuth Flows without SDKs. Okta as IDP. Node as backend.
- If you don't already have an Okta Developer org, create one here.
- Ensure
http://localhost:8080is listed as a trusted CORS origin inSecurity->API.
- Go to
Applications->Applications. - Click
Add Application. - Click
Create New App. - From the dropdown select the following depending on the flow you are setting up:
- Implicit Flow:
Single Page App (SPA). - Authorization Flow:
Web. Sign on method should beOpenID Connect. - PKCE Flow:
Single Page App (SPA). - Resource Owner Flow:
Native app. - Client Credentials Flow:
OAuth Service.
- Implicit Flow:
- Click
Create. - Name the application, and add the following to
Login redirect URIsdepending on the flow you are setting up:- Implicit Flow:
http://localhost:8080/implicit-flow. - Authorization Flow:
http://localhost:8080/auth-flow. - PKCE Floww:
http://localhost:8080/pkce-flow. - Resource Owner Flow:
http://localhost:8080/resource-owner-flow. - Client Credentials Flow:
http://localhost:8080/client-credentials-flow.
- Implicit Flow:
- On the following screen, take note of your
Client ID&Client Secret. You will need these for the Node App. The Implicit Flow and PKCE Flow will only haveClient ID.
- This flow requires a custom scope in your Authorization call which requires a custom Authorization Server. Go to
Security->API. ClickAdd Authorization Server. Add aName,Audience&Description. - On the next screen, take note of your
IssuerURL. You will need this for the Node app. - Go to the
scopestab, and clickAdd Scope. Give it aNameandDescriptionand take note of the name for the Node app. - Tab over to
Access Policiesand clickAdd New Access Policy. Name itClient Credentialsand assign it to the Client Credentials app you made in the previous step. - Your policy should now appear in the side bar. Click
Add Rule.- Name your rule.
- For
Grant Typecheck only theClient Credentialsbox. - User is
Any user assigned the app. - Scopes Requested:
The following scopes: Add the custom scope name you created in previous steps. - Leave the rest of the defasults and click
Create Rule.
- Feel free to tab over to Token Preview and test out the custom scope before implementing in the Node app.
- Download this repository. In terminal,
cdto the folder and runnpm install - Locate
customVars.jsand replace all the variables with your personal Okta Org data created in OKTA DASHBOARD STEPS. - Change
customVars.jsfilename tolocalVars.js. - In terminal, run
node server.js. - In a browser, navigate to
http://localhost:8080to start using the app.