Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 3.5 KB

File metadata and controls

65 lines (43 loc) · 3.5 KB

Authorization Code Flow + PKCE JavaScript Sample and Test

Version: 1.2.9 Build Status

This client uses the OAuth2/OIDC Authorization Code Flow + PKCE to obtain an access token. See the main Cds Authentication samples page README for more information about this flow.

Requirements

  • Node.js 12.6.0+
  • Web Browser with Javascript enabled
    • You will need Google Chrome if you want to run the automated test

Running the sample client

Prerequisites

  • Register an AuthorizationCode client in Cds and ensure that the registered client in Cds contains http://localhost:5004/callback.html, and http://localhost:5004/silent-refresh.html in the list of RedirectUris.
  • Configure the sample using the file appsettings.placeholder.json. Before editing, rename this file to appsettings.json. This repository's .gitignore rules should prevent the file from ever being checked in to any fork or branch, to ensure credentials are not compromised.
  • Replace the placeholders in the appsettings.json file with your TenantID and ClientID obtained from registration. The username and password fields are used for testing and can be left as is.

You can learn more about the config options here.

Running the Sample from the Command Line

  1. Make sure Node.js is installed, installation instructions are available at node.js

  2. Clone the git repository

  3. Install dependencies, using the command line:

    npm ci
  4. Start the http server to host the sample, using:

    npm start
  5. Open a browser and navigate to http://localhost:5004

  6. Click on Login and follow the prompts to log in to Cds

Running the automated test

Test Prerequisites

  1. Make sure the sample client in the section above is running.
  2. Make sure Google Chrome is installed on your test system.
  3. Make sure the version of Chrome matches the version defined for the chromedriver dependency in package.json.
    • If the dependency needs to be updated in package.json, after saving, run npm i in a command prompt inside this folder to update the package.
  4. Update the appsettings.json file with the username and password for the Microsoft account that will be used to log in. The test is only written to work with a personal Microsoft account and must only prompt for only username followed by password (no Two-Factor authentication or other consent or informational prompts). Also if the location of the sample application has been modified then change the url location.

Running the test from the Command Line

Run the command:

npm test

For the main Cds Authentication samples page ReadMe
For the main Cds samples page ReadMe
For the main AVEVA samples page ReadMe