ForgeRock Developer Experience

Step 3. Configure a sample app

In this tutorial, you configure a sample app provided in the ForgeRock JavaScript SDK to connect to the authentication tree/journey you created when setting up your server configuration.

Configuration properties define how the SDK connects to the ForgeRock Identity Platform.

The table below lists the properties that this tutorial requires.

You can click on a value in the Example column and enter your own custom value.

The documentation displays your custom value whenever it is required, rather than the default.

SDK configuration properties
Property Description Example

clientId

The client_id of the OAuth 2.0 client profile to use.

sdkPublicClient

scope

A space-separated list of scopes to request when performing an OAuth 2.0 authorization flow.

openid profile email address phone

serverConfig

An interface for configuring how the SDK contacts the AM server. The interface contains baseUrl and timeout.

serverConfig: {baseUrl}

The base URL of the AM instance to connect to, including port and deployment path.

https://openam-forgerock-sdks.forgeblocks.com/am/

serverConfig: {timeout}

A timeout, in milliseconds, for each request that communicates with AM.

For example, for 5 seconds, specify 5000.

redirectUri

The redirect_uri as configured in the OAuth 2.0 client profile.

https://sdkapp.example.com:8443/callback

realmPath

The realm or realm path in which the tree is configured. The default is the top-level realm; root).

alpha

To configure the tutorial sample

  1. In Terminal, open the forgerock-javascript-sdk project created earlier.

  2. Navigate to samples > embedded-login, and open the src/main.js file.

  3. In the main.js file, update the configuration settings as follows:

    forgerock.Config.set({
      clientId: 'sdkPublicClient',
      redirectUri: 'https://sdkapp.example.com:8443/callback',
      scope: 'openid profile email address phone',
      serverConfig: {
        baseUrl: 'https://openam-forgerock-sdks.forgeblocks.com/am/',
        timeout: 5000
      },
      realmPath: 'alpha', // Self-managed AM: 'root', Cloud AM: 'alpha' or 'beta'.
      tree: 'Login',
    });

You will see these values are populated in the embedded login with process.env.VARIABLE_NAME.

You can choose to leverage the .env.example file in the folder by making a copy in the same directory called .env, and updating the values there. Alternatively, replace the values with your settings directly in the config object as above.

Copyright © 2010-2024 ForgeRock, all rights reserved.