Test the Node.js Application

In this section of the solution, you:

  • Register the sample Node.js web application to integrate it with Oracle Identity Cloud Service for authentication

  • Set up the application to make it use Oracle Identity Cloud Service's SDK for the Node.js programming language

  • Prepare, run, and test the application

Register the Node.js Application

To establish communication with Oracle Identity Cloud Service, the sample Node.js web application needs a Client ID and Secret. You also need to configure API permissions to grant to the application.

  1. In the Identity Cloud Service console, expand the Navigation Drawer, and then click Applications.
  2. In the Applications page, click Add.
  3. In the Add Application dialog box , click Trusted Application.
  4. In the Name and Description fields of the Details pane, enter SDK Web Application, and then click Next.
  5. In the Client pane, select Configure this application as a client now, and then populate the fields of this pane, as follows:
    Field Value
    Allowed Grant Types Select Client Credentials, Refresh Token, and Authorization Code.
    Allow non-HTTPS URLs Select this check box. The application works in non-HTTPS mode.
    Redirect URL http://localhost:3000/callback
    Logout URL http://localhost:3000/logout
    Post Logout Redirect URL http://localhost:3000
  6. In the Client pane, scroll down, select Grant the client access to Identity Cloud Service Admin APIs., enter Identity Domain Administrator and Me in the field below, and then click Next.
  7. In the Resources pane, click Next.
  8. In the Web Tier Policy pane, click Next.
  9. In the Authorization pane, click Finish.
  10. In the Application Added dialog box, note the Client ID and Client Secret values (because your Node.js web application needs these values to integrate with Oracle Identity Cloud Service), and then click Close.
  11. Because you want to integrate this application with Oracle Identity Cloud Service, click Activate.
  12. In the Activate Application? dialog box, click Activate Application.
  13. In the Identity Cloud Service console, click the user name at the top-right of the console, and then click Sign Out.

Set up the Node.js Application

Update the code of the sample Node.js application to make it use Oracle Identity Cloud Service's SDK for the Node.js programming language.

Edit the c:\temp\nodejs\auth.js file, update the file with the following content, and then save the file.

//Oracle Identity Cloud Service connection parameters as a json var
var ids = {
  oracle: {
    "ClientId": '123456789abcdefghij',
    "ClientSecret": 'abcde-12345-zyxvu-98765-qwerty',
    "ClientTenant": 'idcs-abcd1234',
    "IDCSHost": 'https://%tenant%.identity.oraclecloud.com',
    "AudienceServiceUrl" : 'https://idcs-abcd1234.identity.oraclecloud.com',
    "TokenIssuer": 'https://identity.oraclecloud.com/',
    "scope": 'urn:opc:idm:t.user.me openid',
    "logoutSufix": '/oauth2/v1/userlogout',
    "redirectURL": 'http://localhost:3000/callback'
  }
};
module.exports = ids;

For the ClientId and ClientSecret parameter values, use the Client ID and Client Secret that Oracle Identity Cloud Service generated when you registered your Node.js web application. You can obtain the values for the ClientTenant, IDCSHost, and AudienceServiceURL parameters from the Learn About Methods and Functions topic of this solution.

Run the Node.js Application

Prepare, run, and test the sample Node.js web application.

  1. Open a command prompt window, navigate to the c:\temp\nodejs folder, and enter npm install to install all of the necessary modules that are specified in the package.json file of the sample application.
  2. Extract the contents of the NodeJS_sdk.zip file into the application source code's node_modules folder.
    You downloaded this .zip file in the Download the Node.js SDK section of this solution.
  3. Run the node app.js command to start the application.
  4. Open a web browser, access the http://localhost:3000 URL, and then click Log in.
  5. In the Login page, click the red Oracle icon, which appears to the right of or You can log in with.
    The application's login form (the Email and Password fields, and the Log In button) doesn't work. It’s illustrative only.
  6. In the Sign In page, sign in using your Oracle Identity Cloud Service credentials.
    After you sign in to Oracle Identity Cloud Service, the browser is redirected to the /home page. The name of the logged-in user appears at the top-right side of the page.
  7. In the left menu, click My Profile.
  8. Verify that information associated with your profile appears in the center of the page.