Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Set the configuration settings
- const credentials = {
- client: {
- id: config.vigipay.oauth.client_id,
- secret: config.vigipay.oauth.client_secret
- },
- auth: {
- tokenHost: 'http://ebipssso.test.vggdev.com/core',
- tokenPath: '/connect/token',
- authorizePath: '/connect/authorize'
- }
- };
- // Initialize the OAuth2 Library
- const oauth2 = require('simple-oauth2').create(credentials);
- function getAccessToken(param, callback) {
- const tokenConfig = {
- username: config.vigipay.credentials.username,
- password: config.vigipay.credentials.password
- };
- oauth2.ownerPassword
- .getToken(tokenConfig)
- .then((result) => {
- const token = oauth2.accessToken.create(result);
- console.info('Access Token', token);
- callback(responseHandler(201, 'Access token received', result));
- })
- .catch((err) => {
- console.error('Get Access Token Error', err);
- if(err.status && err.message){
- callback(responseHandler(err.status, err.message, err));
- }else
- callback(responseHandler(500, 'Error received', err));
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement