To obtain an OAuth token from ServiceNow in a Bot Framework skill within Power Virtual Agent, you can follow these steps:
const axios = require('axios');
const serviceNowUrl = 'https://yourinstancename.service-now.com/oauth_token.do';
const clientId = 'your_client_id';
const clientSecret = 'your_client_secret';
const scope = 'useraccount';
const data = {
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret,
scope: scope
};
const headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
axios.post(serviceNowUrl, new URLSearchParams(data), { headers })
.then(response => {
const token = response.data.access_token;
console.log('OAuth token:', token);
// use the token to make API requests to ServiceNow
})
.catch(error => {
console.error('OAuth error:', error.message);
});
Asked: 2022-11-11 11:00:00 +0000
Seen: 11 times
Last updated: May 02 '22