Skip to content

opentext/ocp-nodejs-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OCP Node.js Starter Application

Overview

This application demonstrates how to consume the IM services from the OpenText Cloud Platform using Node.js. This is intended to be a server-side or cli app with the simplest possible set-up to get developers started making API calls to an OCP application using the OAuth client_credentials grant.

Technologies

Language

JavaScript

Dependencies

dotenv
Reads in environment variables with overrides in .env.

axios
Promise based HTTP client for the browser and node.js.

Prerequisites

  • Install the latest version of Node JS.
  • You must have a trial set up with an organization and tenant. You will also need to create a test app and have the confidential client ID and secret values ready to use for authentication. For background information on this see the documentation.

Configuration

  • Clone this repository and open it in your IDE. Visual Studio Code can be used for this if you don't have a preferred IDE.

  • Update the .env file and replace the values using the config for your OCP app.

  • Create a file in the root of the project called .env.secret. Copy the following into it and replace the secret value using the config for your OCP app:

    CLIENT_SECRET=replace-with-clientSecret
    

This is for local development purposes only. The .env.secret file should never be committed to source control. The client secret should always be handled using a secure secret management procedure.

Usage

To run the application using Node.js, open a terminal in your IDE and run the following commands (from the project root).

npm install
npm start

As an example to get you started, the application will fetch a token and print the names of the Content Metadata service traits in your app to the console.

You can then add new samples in the ocp directory to make calls to other API endpoints and test interacting with the APIs using JavaScript. You can replace the existing traits code in callOcp and use the token to make other calls.

Background

Authentication

Uses the confidential client id and secret with the client_credentials grant type. See fetchAccessToken for the implementation.

APIs

This example calls the Content Metadata Service and uses the following endpoint:

Trait

  • GET Returns list of all trait definitions

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published