UNPKG

@zeroid/trimble.identity.authorizationcodegranttokenprovider

Version:

An implementation of ITokenProvider for OAuth authorization code grant type

26 lines (22 loc) 992 B
Trimble.Identity.AuthorizationCodeGrantTokenProvider ====== ## Installation `npm install @zeroid/trimble.identity.authorizationcodegranttokenprovider` ## Usage ```javascript 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 ```