Hello, so i am completely stumped on this one. I created an action last Friday to ping my API on post user registration. It worked fine on Friday and today I had a new error about a callback issue. I changed stuff around and it now seems to run but it gets a 401 when I try to ping the API. Ive tried doing a cURL with the same client id and secret as the M2M one I created for the action. and it works fine no auth errors. but for some reason it doesn’t when its running in the action? It’s also working when I test the action and a valid access token is created? I’m baffled, any help on this would really be amazing.
this is my code
const axios = require('axios');
exports.onExecutePostUserRegistration = async (event, api) => {
console.log(event.user)
const options = { method: 'POST',
url: `https://project-pylo.eu.auth0.com/oauth/token`,
headers: { 'content-type': 'application/json' },
data: `{"client_id":"${event.secrets.RULE_APP_CLIENT_ID}","client_secret":"${event.secrets.RULE_APP_CLIENT_SECRET}","audience":"https://project-pylo-api.com","grant_type":"client_credentials"}` };
axios(options)
.then((response) => {
const access_token = response.data.access_token;
const createUserResponse = axios.post("https://eaa6-178-167-195-2.eu.ngrok.io/user", {
name: event.user.name,
email: event.user.email,
sub: event.user.user_id
},
{
headers: {
Authorization: `Bearer ${access_token}`
}
});
console.log(createUserResponse.data);
})
.catch((error) => {
console.error(error);
});
};