Examples
This document describes the steps to run IAM client library examples.
Uncompress domino-node-iam-client-1.5.0.tgz. Let's assume the uncompressed
package is in node-iam-client folder. Then you can find all the examples under
node-iam-client\examples
folder.
Authorization Code flow
Note: IAM Server has to be configured and started before you try this example.
Step 1: Register an application with the type of Server-side application
in IAM Admin Server. Select the scopes you want the application to access in the
registration process.
Step 2: Open examples/authorization_code_flow/config.js
, edit the config file
to match with the application you just registered.
Example:
// The IAM server (with port if it's not 443).
iam_server: 'https://iamserver.com:6443',
// The filepath of IAM server's ca certificate, need to be set when iam cert is issued by an untrusted CA
iam_server_ca_cert: 'node-iam-service/config/certs/ca/server.pem',
// The client identifier and client secret issued to the client during the registration process
client_id: '6e3cfb7b-98ef-44ab-b2c9-7cadd7124012',
client_secret: 'lS1KvykaKAW1gQuTRZpqE633iU+4HMsd6G40fShue1UiRieAJ8f8v3783DhpjtDI',
// The redirection endpoint. After a user successfully authorizes an application,
// the authorization server will redirect the user back to the application with
// either an authorization code or access token in the URL.
redirect_uri: 'https://iamclient.com:3002/cb',
// Scopes the client want to access.
scope: 'openid offline_access das.calendar.read.with.shared das.freebusy',
// The client application port
port: 3002,
You can find the application information in Admin server. client_id and
client_secret are referenced as application id
and application secret
in
Application detail page:
Step 3: Start IAM client example:
cd node-iam-client
# please run `npm install` first if dependencies modules not installed yet.
npm run auth_code_flow
You will see console output like this:
Application starts, please open https://iamclient.com:3002 with Chrome/Firefox/Safari
Step 4: Access client example at https://iamclient.com:3002
, you will be redirect
to IAM login page to login.
Step 5: After login success, you will see a test page like below with access token you just got from IAM server.
Step 6: Then you can play with the access token to access Domino data here.
For available scopes and Domino resources, please refer to Scopes.
- For Get request, just input the get url and click
Try Get URL
button. - For Post request, input the post url and data and click
Try Post URL
button.
Client credential flow
Note: IAM Server has to be configured and started before you try this example.
Step 1: Register a client with the type of Server-side application
in IAM Admin
Server. Select the scopes you want the application to access in the
registration process.
Step 2: Open examples/client_credential_flow/config.js
, edit the config file
to match with the client info you just registered.
Step 3: Run example from the command line, you will see console output like this
cd node-iam-client
# please run `npm install` first if dependencies modules not installed yet.
npm run client_flow
Exchange token through client credential flow and do introspection:
{
active: true,
client_id: '6e3cfb7b-98ef-44ab-b2c9-7cadd7124012',
exp: 1541145200,
iat: 1541144600,
iss: 'https://iamserver.com',
jti: 'abUWWc15Nwecnmiyzn2R9YY_L8lmBe55P9l3g3xUf89',
scope: 'openid offline_access das.calendar.read.with.shared das.freebusy',
}
Implicit code flow
Step 1: Register a client with the type of Single-page application
in IAM Admin
Server. Select the scopes you want the application to access in
registration process.
Step 2: Open examples/implicit_code_flow/config.js
, edit the config file to
match with the client info your just registered.
Step 3: Run example from command line, you will see console output like this:
cd node-iam-client
# please run `npm install` first if dependencies modules not installed yet.
npm run implicit_flow
Application starts, please open https://iamclient.com:3002 with Chrome/Firefox/Safari