Authorization code sample

Introduction

A simple way to integrate a web application with IBM Security Verify is to use the OpenID Connect Authorization Code flow. To help you with this, we've provided a sample application which uses the openid-connect library so you can see how it works.

In this guide you'll learn how to configure a sample application from the developer portal.

Prerequisites

You need to have registered an application using the Developer Portal in your IBM Security Verify tenant. See Using the Developer Portal for details. During registration, pick Authorization Code as the grant type.

You need to have node.js installed on the system where you will run the sample application. Download node.js.

You need to have a browser installed on the system where you will run the sample application.

Download the sample application

  1. Access the Developer Portal of your IBM Security Verify tenant. Usually you will find this as a tile in the end user launchpad.

  2. From the My applications page, select your application and then click the App setup link that appears at the top of the details sidebar.

  3. Select the node.js tile.

  4. Select the Download app button. This will download a ZIP file containing the sample application.

1033

Download sample application

  1. Extract the ZIP file to the location where you will run the sample application.
  2. Copy the generated snippet from the developer portal UI.
  3. Create a .env file in the root of your project, paste the snippet provided and click save.

Install modules

In the directory that was created when you extracted the ZIP file, run the following command to install the node modules required by the sample application:

npm install

added 61 packages, and audited 62 packages in 2s

found 0 vulnerabilities

Start the sample application

In the directory that was created when you extracted the ZIP file, run the following command to start the sample application:

npm run start

> [email protected] start
> node server.js

Server started
Navigate to http://localhost:3000

The application is now running on IP address 127.0.0.1 (localhost) on port 3000.

Test single sign-on

Using a browser on the same system where you have started the sample application, connect to:
http://localhost:3000.

All being well, you should be immediately redirected to the login page of your IBM Security Verify tenant.

Login to your IBM Security Verify tenant. You can use any authentication method available.

Once authentication is complete, you'll be re-directed back to your sample application. It will complete the single sign-on flow to get access to identity information for the user that authenticated. The information received is displayed in the browser:

📘

Available attributes

The attributes that are shared from your IBM Security Verify tenant to the application are controlled by the requested OpenID Connect scopes and by the configuration of the Developer Portal (which is set by your tenant administrator).

If you want to receive additional information, try adding additional scopes to the .env file of the sample application:

SCOPE=openid profile email phone