Auth0 Home Blog Docs

How do I access user’s picture within a hook?


#1
const Chatkit = require('@pusher/chatkit-server')

const chatkit = new Chatkit.default({
  instanceLocator: 'v1:us1:6759a97c-d77e-4a06-89f4-3df55679df5e',
  key: 'KEY',
})

module.exports = function (user, context, cb) {

  chatkit
    .createUser({
      id: `auth0|${user.id}`,
      name: user.email,
      avatarURL: user.picture // <<<<< HOW DO I ACCESS PICTURE?
    })
    .then(() => cb())
    .catch((err) => {
      console.log(err)
      cb(err)
    });
}

From within a Post User Registration hook I would like to access my user’s picture. However user.picture is undefined.

I tried adding picture to user_metadata in a rule but then I realised I cannot access user_metadata from the hook either :open_mouth:

What should I do?


#2

Is it okay to bump this? Still not figured it out!


#4

This may not be the exact answer your are looking for, but why can’t you just use a rule - you can definitely access the picture there, and it may be a better solution since as the picture changes, you will be able to keep it updated.

As you can see, the picture is easily accessible via a rule using the user.picture property

image

Also, the rule will fire when the user first signs up.

Sahil