@zeroid/trimble.identity.authorizationcodegranttokenprovider
v0.1.0
Published
An implementation of ITokenProvider for OAuth authorization code grant type
Downloads
8
Maintainers
Readme
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