Skip to content

Commit 893121c

Browse files
author
Ruslan Tereshchenko
committed
[ter] created get access token applet
1 parent dec45c3 commit 893121c

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

lib/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const responseHandler = (callback, { parse = true } = {}) => res => {
3838
}
3939

4040
if (callback) {
41-
return callback(errors, parse ? parsedData : rawData);
41+
return callback(errors, !errors && (parse ? parsedData : rawData) || null);
4242
}
4343
});
4444
};

samples/applets/get-access-token.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* to run get access token applet from the project root folder type in your console:
3+
* > node samples/applets/get-access-token <cliend_id> <client_secret> <email> <password>
4+
* <cliend_id>, <client_secret>, <email>, <password> - are required params
5+
*/
6+
7+
'use strict';
8+
9+
const [
10+
clientId,
11+
clientSecret,
12+
username,
13+
password,
14+
] = process.argv.slice(2);
15+
16+
const { oauth2: { requestToken: getAccessToken } } = require('../../lib')({
17+
credentials: Buffer.from(`${clientId}:${clientSecret}`).toString('base64'),
18+
production: false,
19+
});
20+
21+
getAccessToken({
22+
username,
23+
password,
24+
}, (err, res) => {
25+
if (err) {
26+
console.error(err);
27+
} else {
28+
console.log(res);
29+
}
30+
});

0 commit comments

Comments
 (0)