-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.js
More file actions
43 lines (33 loc) · 940 Bytes
/
Copy pathauth.js
File metadata and controls
43 lines (33 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const axios = require('axios');
const qs = require('qs');
const data = qs.stringify({
'scope': 'oob',
'grant_type': 'client_credentials'
});
var config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api-sandbox.getnet.com.br/auth/oauth/v2/token',
headers: {
'Accept': 'application/json, text/plain, */*',
'authorization': 'Basic MTMyMGVhNDktNmFkNC00MmY1LTg5ZmYtYTA5OTM1NjNjYWE5OmRmNTRiOGEzLWQ5MjItNDMxNy05MjE5LTczMGU2YWZkZTAwZg==',
'Content-Type': 'application/x-www-form-urlencoded'
},
data: data
};
async function Auth() {
return await axios(config)
.then(function (response) {
// console.log(JSON.stringify(response.data));
return response.data;
})
.catch(function (error) {
// console.log(error);
return error;
})
};
module.exports.Auth = Auth;
// (async () => {
// const token = await Auth();
// console.log(token?.access_token);
// })();