To authenticate separately in two different front-end apps with the same API using Okta, Web API 2, and Angular 2, you can follow these steps:

  1. Set Up Okta for Authentication:

    • Create an Okta developer account if you don't have one already (
    • Set up an Okta application for each of your front-end apps (Angular 2 apps). Obtain the client ID and client secret for each app.
  2. Set Up Web API 2 for Authentication:

    • Configure your Web API 2 application to use Okta as the identity provider. You can use the Okta ASP.NET SDK or Okta OIDC Middleware to handle authentication and authorization.
  3. Configure Front-End Apps (Angular 2 Apps):

    • For each front-end app (Angular 2 app), configure the Okta authentication settings. Use the Okta client ID and configure the redirect URIs to your front-end app URLs.
  4. Implement Authentication Flow:

    • In each front-end app, implement the Okta authentication flow. This typically involves redirecting users to Okta's login page when they are not authenticated, and then handling the callback after successful authentication to obtain an access token.
  5. Store Tokens Securely:

    • After successful authentication, store the access token securely in the front-end app. You can use browser storage mechanisms such as sessionStorage or secure HttpOnly cookies.
  6. Make API Requests with Tokens:

    • When making API requests from each front-end app to the shared Web API 2, include the access token in the Authorization header. The access token will be validated on the server-side using Okta.
  7. Handle CORS:

    • If your front-end apps are hosted on different domains from the Web API 2, make sure to handle CORS (Cross-Origin Resource Sharing) properly to allow the requests from different origins.
  8. Separate Okta Applications:

    • Ensure that each front-end app uses a separate Okta application (with different client IDs) to avoid conflicts with authentication and authorization.
  9. Manage User Sessions:

    • If required, manage user sessions separately in each front-end app to provide individual user experiences.
  10. Test and Debug:

  • Test each front-end app separately to ensure that the authentication flow works correctly with Okta and that the API requests are being made with the correct access tokens.

By following these steps, you can authenticate separately in two different front-end apps using the same API with Okta as the identity provider. Each front-end app will use its own Okta application to handle authentication, and the shared API (Web API 2) will validate the access tokens provided by each front-end app's authentication flow. This setup allows you to maintain separate user sessions and user experiences in each front-end app while sharing the same API backend.

Have questions or queries?
Get in Touch