I am trying to create a script in the flow script widget to pull an address book from the contact center. I have created a server-to-server OAuth app on market place and I’m able to get an access token using postman without issue. My problem comes in when I try to do this on the flow script widget. Here is what I have for my script:
async function main () {
//header for auth token
const auth = 'Basic REDACTED;
const content_type = ‘application/x-www-form-urlencoded’;
//body for auth token
const grant_type = ‘account_credentials’;
const account_id = ‘REDACTED’;
const token_url = ‘https://zoom.us/oauth/token?grant_type=’ + grant_type + ‘&account_id=’ + account_id;
//const headers = ‘{headers : {Authorization:’ + auth + ‘, Content-Type:’ + content_type + ‘} }’;
try {
const r = await req.post(token_url, { headers: {‘Authorization’: auth, ‘Content-Type’: content_type} });
return r;
} catch (error) {
return error;
}
}
Currently this just returns {}. I think I might be passing in the header incorrectly but I’m not sure.