2.0.1 • Published 12 months ago
@nuskin/service-token v2.0.1
@nuskin/service-token
This library is used to create a new NextGen Service Token. The token created is a JSON Web Token (JWT).
For additional information about JSON Web Tokens, click here.
Note: This package was previously published under the
@nextgenscope as@nextgen/service-token. It has now moved to the@nuskinscope. Please update your dependencies accordingly.
Installing
Using yarn:
yarn add @nuskin/service-tokenExample usage
const { decodeJWT, isTokenStale, getServiceToken } = require('@nuskin/service-token')
const clientId = 'myFakeId'
const clientSecret = 'myFakeSecret'
const tokenUrl = 'https://the-token-store.com/some-endpoint'
const scopes = [
'internal:fake:read',
'internal:fake:write'
]
try {
// create a new token with desired scopes
const token = await getServiceToken(clientId, clientSecret, tokenUrl, scopes)
// check if the token is stale
if(isTokenStale(token)){
// the token is stale and I should do something here if it is stale.
}
// decode the token
console.log(decodeJWT(token))
} catch (error){
console.error(error)
}Resources
SDK Documentation not currently published