Please include the following information in your post:
- Which SDK this is regarding: @auth0/nextjs-auth0
- SDK Version: 1.6.1
- Platform Version: node v14.18.1
- Code Snippets/Error Messages/Supporting Details/Screenshots:
Hi,
I try to fetch user_metadata.
I did two things so far:
Created Action
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'https://<AUTH0-DOMAIN>.com';
api.idToken.setCustomClaim(`${namespace}/user_metadata`, event.user.user_metadata);
};
Changed API Route
I’ve changed the API route in pages/api/[...auth0].js
import { handleAuth, handleCallback } from "@auth0/nextjs-auth0";
const afterCallback = async (req, res, session, state) => {
console.log(session);
return session;
}
export default handleAuth({
async callback(req, res) {
try {
await handleCallback(req, res, { afterCallback });
} catch (error) {
res.status(error.status || 500).end(error.message);
}
}
});
If I understand it correctly I should see the user_metadata now in the session object but I don’t see it.
In the end, I’d like to fetch it from the frontend via the useUser hook.
Thanks for your help!