I am having some trouble with a Citrix ShareFile API. Right now we've got two environments. The first one I am able get the token and make calls without issue, the second is a new POC environment we are testing, I have basically copied my code, updated my environment variables with new API key and secret, etc and cannot get an access token.
Whenever I run my script to get an access token I get a 200 response but get the message "Error retrieving Microsoft Graph Access Token." I am having a hard time finding the issue, whether it's in my code or somewhere else
Here is my code if this helps at all
let secrets;
let errorCallback;
const getAccessToken = async () => {
try {
const getAccessTokenRequest = {
url: `https://${subDomain}.sharefile.com/oauth/token`,
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
data: `grant_type=password&client_id=${clientId}&client_secret=${clientSecret}&username=${userName}&password=${password}`
};
const response = await axios(getAccessTokenRequest);
const accessToken = (((response || {}).data || {}).access_token || null);
return accessToken ? accessToken : console.log(`Error retrieving Microsoft Graph Access Token.`);
} catch (err) {
console.log(`Error retrieving Citrix Sharefile Access Token. Error: ${err}`);
}
};
module.exports = async (input, callback, error) => {
try {
secrets = input.secrets;
errorCallback = error;
let request = input.request;
const accessToken = await getAccessToken();
request.headers.Authorization = `Bearer ${accessToken}`;
callback(request);
} catch (err) {
error(err);
}
};