Skip to content

Simple pure vanilla javascript examples with Okta AuthJS SDK

Notifications You must be signed in to change notification settings

noinarisak/okta-pure-vanilla-javascript-authjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sample Pure Vanilla JS with Okta AuthJS SDK

Very simple pure vanilla javascript example of using the Okta AuthJS SDK.

Pre-requirements

Quick-start

An OpenID Connect application was create on your Okta org. Using the following instructions:

  • Instructions for creating an application, instructions here
  • Assigned one user to the application, instructions here
  • Update your Okta's Trusted Origins for your application. To do this, follow the steps found under the "Trusted Origins tab" section in our API Security help page

Update the index.html file with your Okta Org URL, CLIENT_ID, REDIRECT_URI, and ISSUER from the above instructions.

    // Bootstrap the AuthJS Client
    const authClient = new OktaAuth({
        // Org URL
        url: 'https://{OKTA_ORG_URL}',
        // OpenID Connect APP Client ID
        clientId: '{OKTA_OIDC_CLIENT_ID}',
        // Trusted Origin Redirect URI
        redirectUri: 'http://localhost:8080/login/callback',
        // Issuer
        issuer: 'https://{OKTA_ORG_URL}/oauth2/default',
    });

Run it, using the serve and custom properties defined in serve.json file.

npx serve -l 8080 -c serve.json

Navigate to http://localhost:8080 with your prefer Browser. You will prompted for Username and then Password. Use an user that exist in that Okta Org that you have configured. Using Browser dev tool, ie (Right-click > Inspect) after a successful sign in, the console should identify the id_token that was minted by Okta Authorization Server.

Author

Inspiration

About

Simple pure vanilla javascript examples with Okta AuthJS SDK

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages