Step 2. Configure connection properties
PingOne Advanced Identity Cloud JavaScript
There are two projects in this tutorial that require configuration:
- Backend API server
-
A backend REST API server that uses a confidential OAuth 2.0 client to contact the authorization server. The API server handles storage and retrieval of your personal "Todo" items.
- Client ReactJS app
-
The front-end client app, written in ReactJS, that handles the UI and authentication journeys.
Configure the API server app
-
In the IDE of your choice, open the
sdk-sample-appsfolder you cloned previously. -
Copy the
.env.examplefile in thesdk-sample-apps/javascript/todo-apifolder and save it with the name.envwithin this same directory.The file contains configuration to connect to the confidential OAuth 2.0 client you created earlier:
Example default API serversdk-sample-apps/todo-api/.envfile# 'AIC' or 'PINGONE' SERVER_TYPE= # AM URL for AIC or PingOne base URL with env ID for PingOne SERVER_URL= PORT= # 'alpha' or 'bravo' for AIC server type. Not used for PingOne. REALM_PATH= # Confidential client ID for AIC or WebApp public client ID for PingOne REST_OAUTH_CLIENT= # Confidential client secret for AIC. Not used for PingOne. REST_OAUTH_SECRET= -
Update the configuration block with the details of your server environment.
- SERVER_TYPE
-
Ensures the sample app uses the correct behavior for the different servers it supports, for example what logout parameters to use.
For PingOne Advanced Identity Cloud tenants, specify
AIC. - SERVER_URL
-
The URL of the server to connect to, including the deployment path of the Access Management component.
Identity Cloud example:
https://openam-forgerock-sdks.forgeblocks.com/am - PORT
-
The port number on which to run the TODO API server.
You’ll need this port number when configuring the client app to connect to the TODO API server.
If not specified, the TODO API server defaults to running on port
9443 - REALM_PATH
-
The realm in which the confidential OAuth 2.0 client profile is configured.
Usually,
alphaorbravofor Advanced Identity Cloud. - REST_OAUTH_CLIENT
-
The client ID of the confidential OAuth 2.0 application you created earlier.
For example,
sdkConfidentialClient - REST_OAUTH_SECRET
-
The secret of the confidential OAuth 2.0 application you created earlier.
For example,
5tr0ngP@S5w0rd!
The result will resemble the following:
Example completed API serversdk-sample-apps/todo-api/.envfile# 'AIC' or 'PINGONE' SERVER_TYPE='AIC' # AM URL for AIC or PingOne base URL with env ID for PingOne SERVER_URL='https://openam-forgerock-sdks.forgeblocks.com/am' PORT=9443 # 'alpha' or 'bravo' for AIC server type. Not used for PingOne. REALM_PATH='alpha' # Confidential client ID for AIC or WebApp public client ID for PingOne REST_OAUTH_CLIENT='sdkConfidentialClient' # Confidential client secret for AIC. Not used for PingOne. REST_OAUTH_SECRET='5tr0ngP@S5w0rd!' -
Save your changes.
Configure the ReactJS client app
-
In the IDE of your choice, open the
sdk-sample-appsfolder you cloned previously. -
Copy the
.env.examplefile in thesdk-sample-apps/javascript/reactjs-todo-oidcfolder and save it with the name.envwithin this same directory.Example clientsdk-sample-apps/javascript/reactjs-todo-oidc/.envfileAPI_URL= DEBUGGER_OFF=true DEVELOPMENT= REALM_PATH=alpha WEB_OAUTH_CLIENT= SCOPE= WELLKNOWN_URL= -
Update the configuration block with the details of your server environment.
- API_URL
-
The URL and port number on which you are running the TODO API backend server.
For example,
http://localhost:9443 - DEBUGGER_OFF
-
Set to
true, to disabledebugstatements in the app.These statements are for learning the integration points at runtime in your browser.
When you open the browser’s developer tools, the app pauses at each integration point. Code comments are placed above each one explaining their use.
- DEVELOPMENT
-
When
true, this provides better debugging during development. - REALM_PATH
-
The authentication realm.
For example,
alpha - WEB_OAUTH_CLIENT
-
The client ID of your public OAuth 2.0 application in PingOne Advanced Identity Cloud.
For example,
sdkPublicClient - SCOPE
-
The scopes you added to your public OAuth 2.0 application.
Scopes should be space-separated, and the entire value should be enclosed in single-quotes.
For example,
'openid profile email address' - WELLKNOWN_URL
-
The
.well-knownendpoint from your server.How do I find my PingOne Advanced Identity Cloud
.well-knownURL?You can view the
.well-knownendpoint for an OAuth 2.0 client in the PingOne Advanced Identity Cloud admin console:-
Log in to your PingOne Advanced Identity Cloud administration console.
-
Click Applications, and then select the OAuth 2.0 client you created earlier. For example, sdkPublicClient.
-
On the Sign On tab, in the Client Credentials section, copy the Discovery URI value.
For example,
https://openam-forgerock-sdks.forgeblocks.com/am/oauth2/alpha/.well-known/openid-configuration
If you are using a custom domain, your
.well-knownis formed as follows:https://<custom-domain-fqdn>/.well-known/openid-configurationLearn more in Access OIDC configuration discovery endpoint.
For example,
https://openam-forgerock-sdks.forgeblocks.com/am/oauth2/realms/alpha/.well-known/openid-configuration -
The result will resemble the following:
Example clientsdk-sample-apps/javascript/reactjs-todo-oidc/.envfileAPI_URL=http://localhost:9443 DEBUGGER_OFF=true DEVELOPMENT=true REALM_PATH=alpha WEB_OAUTH_CLIENT=sdkPublicClient SCOPE='openid profile email address' WELLKNOWN_URL=https://openam-forgerock-sdks.forgeblocks.com/am/oauth2/realms/alpha/.well-known/openid-configuration -
Save your changes.