Adding claims via nextjs / handleProfile

(I am using the @auth0/nextjs-auth0 SDK.)

I am trying to add some custom claims to my user session, and so am overriding the profile handler in handleAuth, in my /pages/api/auth/[...auth0].js file:

import { handleAuth, handleProfile } from '@auth0/nextjs-auth0';

const afterRefresh = async (req, res, session) => {
  console.log('in afterRefresh')

export default handleAuth({
  async profile(req, res) {
    try {
      await handleProfile(req, res, { afterRefresh, refetch: true })
    } catch (error) {
      res.status(error.status || 500).end(error.message)

However, my afterRefresh function never seems to be called, even when I pass refetch: true.

Has anyone had success with this? Any tips?


Figured out the issue… the argument is afterRefetch, not afterRefresh

1 Like

Perfect! Thanks for sharing that with the rest of community!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.