endpoint(module.exports, async function(request)
{
const url = 'https://auth.us-central1.gcp.commercetools.com/oauth/token';
const data = 'grant_type=client_credentials&scope=manage_project:imagecon';
const auth = {
username: 'lWyJvSKrmUbwGfSz8UN-9tHU',
password: 'UwBddfzynLovKsCZJKy1mqReVn0WEGvN'
};
var jsonResponse;
try {
var options = {
method: 'POST',
uri: url,
auth:auth,
form: {
// Like <input type="text" name="name">
grant_type: 'client_credentials',
scope: 'manage_project:imagecon'
},
json: true // Automatically parses the JSON string in the response
};
console.log('executing request');
jsonResponse = await requestPromise(options);
console.log('executed request');
return jsonResponse;
} catch(e) {
console.log("Error getting auth");
console.log(e);
return e;
}
}
)