Skip to content

Use Okta Angular SDK for runtime configuration loading in standalone Angular applications

License

Notifications You must be signed in to change notification settings

oktadev/okta-angular-standalone-runtime-config-example

Repository files navigation

Angular Standalone Runtime Configuration Example

This repository contains a working example of adding Okta Angular SDK to a standalone Angular project and how to load the Okta authentication configuration at runtime. Please read Flexible Authentication Configurations in Angular Applications Using Okta for a detailed guide through.

Prerequisites

  • Node 18 or greater
  • Okta CLI
  • Angular CLI
  • Your favorite IDE
  • A web browser with good debugging capabilities
  • Terminal window

Okta has Authentication and User Management APIs that reduce development time with instant-on, scalable user infrastructure. Okta's intuitive API and expert support make it easy for developers to authenticate, manage and secure users and roles in any application.

Getting Started

To run this example, run the following commands:

git clone https://github.com/oktadev/okta-angular-standalone-runtime-config-example.git
cd okta-angular-standalone-runtime-config-example
npm ci

Create an OIDC Application in Okta

Create a free developer account with the following command using the Okta CLI:

okta register

If you already have a developer account, use okta login to integrate it with the Okta CLI.

Provide the required information. Once you register, create a client application in Okta with the following command:

okta apps create

You will be prompted to select the following options:

  • Type of Application: 2: SPA
  • Redirect URI: http://localhost:4200/login/callback
  • Logout Redirect URI: http://localhost:4200

The application configuration will be printed to your screen:

Okta application configuration:
Issuer:    https://<OKTA_DOMAIN>.okta.com/oauth2/default
Client ID: <CLIENT_ID>

Update src/api/config.json with your Okta settings.

{
    "issuer": "https://{yourOktaDomain}/oauth2/default",
    "clientId": "{yourClientId}"
}

Start the app by running

npm start

Run Tests

Projects are incomplete without unit tests. Run the unit tests in this project by using the following command line operation

npm run test

Open up *.spec.ts files to see examples of how to mock Okta libraries for isolated unit testing.

Links

This example uses the following open source libraries from Okta:

Help

Please post any questions as comments on the blog post, or visit our Okta Developer Forums.

License

Apache 2.0, see LICENSE.

About

Use Okta Angular SDK for runtime configuration loading in standalone Angular applications

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published