Dear Team,
I am relatively new and trying to enrich my user profile using onExecutePostLogin. Here is simple snippet
exports.onExecutePostLogin = async (event, api) => {
const axios = require('axios');
const namespace = 'https://dhanman.com';
let access_token = await axios.post(`https://${event.secrets.auth0_domain}/oauth/token`, {
"client_id": event.secrets.client_id,
"client_secret": event.secrets.client_secret,
"audience": "http://PostLoginApi",
"grant_type": "client_credentials"
});
let users_response = await axios.get(`<mysite>/v1/users/${event.user.email}`, {
headers: {
'Authorization': `Bearer ${access_token.data.access_token}`
}
});
if(users_response.data){
api.accessToken.setCustomClaim(`${namespace}/dhanman_id`, users_response.data.id);
api.idToken.setCustomClaim(`${namespace}/dhanman_id`, users_response.data.id);
}
};
The error I am facing is below
{
"error": "access_denied",
"error_description": "Cannot find module 'axios'\nRequire stack:\n- /data/io/node18-actions/93635820-6a85-4e93-916c-f21eb9a1887a/webtask.js"
}
and when I use import axios from “axios”;
It gives error that import is not allowed outside module.
Any help is much appreciated.
Thank you
B2A