@zeroid/trimble.identity.implicitgranttokenprovider
v0.1.0
Published
An implementation of ITokenProvider for OAuth password grant type
Downloads
3
Maintainers
Readme
Trimble.Identity.ImplicitGrantTokenProvider
Installation
npm install @zeroid/trimble.identity.implicitgranttokenprovider
Usage
var ImplicitGrantTokenProvider = require('@zeroid/trimble.identity.implicitgranttokenprovider');
var tokenProvider = new ImplicitGrantTokenProvider(endpointProvider, 'consumerKey', 'https://redirect.url');
if (window.location.hash && window.location.hash.includes('access_token='))
tokenProvider.decodeHash(window.location.hash)
.then(() => {
tokenProvider.retrieveToken()
.then((token) => {})
.catch(() => {});
})
.catch(() => {});
else
tokenProvider.getOAuthRedirect('state')
.then((redirect) => { window.location.replace(redirect); })
.catch(() => {})