Hi, I’m trying to add user permissions to my Id token to consume them later on the client side of my Next.js 14 based app, I successfully added roles to the Id token, However i’m having hard time including permissions as well, I took reference of following documentation and i also have attached the action code that i added from Auth0 dashboard, Any help would be greatly appreciated, thanks!
Link to documentation explaining user’s permssions:-
My Actions Code:-
const axios = require('axios');
exports.onExecutePostLogin = async (event, api) => {
let config = {
method: 'get',
maxBodyLength: Infinity,
url: `https://login.auth0.com/api/v2/users/${event.user.user_id}/permissions`,
headers: {
'Accept': 'application/json'
}
};
axios.request(config)
.then((response) => {
console.log("====> Auth Data", JSON.stringify(response.data));
// Not sure what needs to be done here in order to receive it as a field inside token
api.idToken.setCustomClaim(`${namespace}/permissions`, JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
};
I also tried to console inside my action code and later checked it from monitoring tab to see if log is there but nothing got printed there as well.
Also is this recommended way to work with permissions? My primary requirement is to load a specific piece of UI based on whether the user has right permissions or not.