0.1.0 • Published 5 years ago

@zeroid/trimble.identity.authorizationcodegranttokenprovider v0.1.0

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
5 years ago

Trimble.Identity.AuthorizationCodeGrantTokenProvider

Installation

npm install @zeroid/trimble.identity.authorizationcodegranttokenprovider

Usage

var AuthorizationCodeGrantTokenProvider = require('@zeroid/trimble.identity.authorizationcodegranttokenprovider');
var tokenProvider = new ImplicitGrantTokenProvider(endpointProvider, 'consumerKey', 'consumerSecret', 'https://redirect.url');
// if query string contains 'access_token='
    tokenProvider.validateQuery(queryString)
        .then(() => {
            tokenProvider.retrieveToken()
                .then((token) => {})
                .catch(() => {});
        })
        .catch(() => {});    

// otherwise instruct the client to redirect
    tokenProvider.getOAuthRedirect('state')
        .then((redirect) => { /* for the client browser to redirect */ })
        .catch(() => {})

// ***NOTE*** this code is intended for use on a node.js server, do not run in the browser