can-pass-verify provides utility functions for working with the can-pass tokens.
npm install can-pass-verify
or
yarn add can-pass-verify
- get header helper
import canPass from 'can-pass-verify/lib/shares/utils';
const authorization = canPass.getHeaderHelper(headers, 'Authorization');
- verify access token
- get new access token
- get token
import canPass from 'can-pass-verify';
import fetch from 'node-fetch';
// global config
canPass.config({
canPassApi: process.env.app_can_pass_api,
fetch,
});
let u = await canPass.verify(accessToken);
// refreshAccessToken
u = await canPass.refreshAccessToken(refreshToken, {
client_secret: '<your client secret - never publish it>',
client_id: '<your client id>',
});
// getToken
u = await canPass.getToken(
{
code: '<code is return from login process>',
redirect_uri: '<redirect_uri must match with one send through login process>',
},
{
client_secret: '<your client secret - never publish it>',
client_id: '<your client id>',
},
);