Creating a web application to integrate with Okta

The following outlines the key steps for creating a web application to integrate with Okta and getting the access token.

For complete and detailed instructions, please refer to the guides.

Guide 1: https://developer.okta.com/docs/guides/implement-grant-type/authcode/main/

Guide 2: https://developer.okta.com/docs/guides/validate-access-tokens/dotnet/overview/

Step 1: Create App Integration.

  1. In Okta menu, select the Applications drop-down list > Applications page, then select Create App Integration button to create a new app integration.


  2. Select OIDC-OpenID Connect radio button under Sign-in method, and select Web Application radio button under Application Type, then click Next.


  3. Write down the App integration name which is appeontest, select the check box of Client Credentials, and write down the Sign-in redirect URIs which is http://localhost:5099/authorization-code/callback.


  4. Select Allow everyone in your organization to access radio button under Controlled access (you can select the button according to your actual needs), and then click Save.


Step 2: Write down the following information.

  • Client ID: 0oa2gio6k8k1kJDGQ5d7

  • Client secret: Z6qh64ih-SGliIN-6U0r0Ycyd4MYayM_WDdYaJAW

  • Okta domain: dev-02923419.okta.com

  • Sign-in redirect URIs: http://localhost:5099/authorization-code/callback



Step 3: Add Person.

In Okta menu, select the Directory drop-down list > People page, then select Add Person to write down the basic information and click Save.


Step 4: Get the code.

  1. The template of the code URI is as follows. You can fill in your information to get the code URI.

    https://${yourOktaDomain}/oauth2/default/v1/authorize?client_id=0oabucvy
    c38HLL1ef0h7&response_type=code&scope=openid&redirect_uri=https%3A%2F%
    2Fexample.com&state=state-296bc9a0-a2a2-4a57-be1a-d0e2fd9bb601
    

    Note

    The state consists of random numbers.

    Get the code URI:

    https://dev-02923419.okta.com/oauth2/default/v1/authorize?client_id=0oa2gio6k8k1kJDGQ5d7

    &response_type=code&scope=openid&redirect_uri=http%3A%2F%2Flocalhost:5099/authorization-

    code/callback&state=state-296bc9a

  2. Access the code URI through a browser, sign in with your Okta username and password, and return the code after successful verification.


    For example, if jump to the URI "http://localhost:5099/authorization-code/callback?code=o1IvY6bgkJ_WNHxJDdfCEOJVgOeTckt7G_xa4hdW8_o&state=state-296bc9a", the code will be "o1IvY6bgkJ_WNHxJDdfCEOJVgOeTckt7G_xa4hdW8_o".

Step 5: Get the token by Postman.

  1. In Okta menu, select the Security drop-down list > API page to get the Issuer URI which is https://dev-02923419.okta.com/oauth2/default, and then click default for more information.


  2. Check the Metadata URI in Settings page.


  3. Access the URI by Postman or web browsers to get the token endpoint: https://dev-02923419.okta.com/oauth2/default/v1/token.


  4. Get the access token by Oauth2.


  5. Check the token by the JWT website (https://jwt.io).