-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathretrieve_token.js
More file actions
32 lines (29 loc) · 817 Bytes
/
retrieve_token.js
File metadata and controls
32 lines (29 loc) · 817 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
require('dotenv').config();
const APPLICATION_ID = process.env.APPLICATION_ID;
const CLIENT_ID = process.env.CLIENT_ID;
const CLIENT_SECRET = process.env.CLIENT_SECRET;
const url = "https://api-sb.bofa.com/authn/v1/client-authentication";
data = {
'applicationID' : APPLICATION_ID,
'authn' :
{ 'client_id': CLIENT_ID, 'client_secret': CLIENT_SECRET }
}
fetch(url, {
method : 'POST',
headers : {
'Content-Type' : 'application/json'
},
body: JSON.stringify(data),
})
.then(response => {
if(!response.ok) {
throw new Error(`Your response is NOT OK! The error code is ${response.status} : ${response.statusText}`)
}
return response.json()
})
.then(data => {
console.log(data);
})
.catch(error => {
console.error(`You encounter the error ${error}`)
})