0.0.1 • Published 4 years ago

@plusauth/rest-client v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

plusauth-js-rest

Helper library for interacting with PlusAuth REST API intent upon to be used in NodeJS and browser environments.

Table Of Content 1. Installation 2. Usage 3. Docs

Installation

From PlusAuth CDN:

<!-- Latest release -->
<script src="https://unpkg.com/plusauth-js-rest@0.0.1-alpha.2/dist/plusauth-js-rest.min.js"></script>

With npm:

$ npm install plusauth-js-rest

or with yarn

$ yarn add plusauth-js-rest

Usage

CDN Usage

The library will be exposed to global as PlusAuthRest

Initialize it like following:

const authToken = '<ACCESS_TOKEN>'
const plusAuth = new PlusAuthRest('https://<YOUR_TENANT_ID>.plusauth.com', { token: authToken })

NPM Usage

import PlusAuthRest from 'plusauth-web'

const authToken = '<ACCESS_TOKEN>'
const plusAuth = new PlusAuthRest('https://<YOUR_TENANT_ID>.plusauth.com', { token: authToken })

Replacing Token

Generally you may need to replace PlusAuth REST API token because its lifetime could end. In this case updating options.token will be enough to change used token.

const initialToken = 'INITIAL_TOKEN'
const plusAuth = new PlusAuthRest('https://<YOUR_TENANT_ID>.plusauth.com', { token: initialToken })

plusAuth.apis.getAll().then( function (res){
// retrieved with initial token
console.log(res)
})

plusAuth.options.token = 'NEW_TOKEN'

plusAuth.apis.getAll().then(function (res){
// Retrieved with new token
console.log(res)
})

Docs

For API docs visit here

0.0.1

4 years ago