How to pass user metadata in social logins

I am wondering how to set the user metadata for user registration via social connections. When logging in with credentials, this works without any problems out of the box. We can simply add the user metadata as follows.

  connection: "Username-Password-Authentication",
  email: email,
  password: password,
  user_metadata: {
    test: "test"

We would like to offer social logins like Google, Facebook and Twitch. But there is no way to write the user metadata.

The following parameters are not allowed on the /authorize endpoint: user metadata

  connection: 'twitch',
  userMetaData: { role: 'xyz' },

We have different roles and different custom universal login pages where users can register. We want to define the role depending on where the user sign up.

This is a standard use case. How do you solve this with Auth0? I have searched the whole internet and have not found anything.

Hi @ArkasDev,

You can set a Social User’s metadata when they first sign up by using a Post-Login Action script.

Whenever a user signs up, they automatically log in as well. Because of this, you can check if the user’s login_count equals 1 and if the connection is social, then set the user_metadata on the user’s first login.

exports.onExecutePostLogin = async (event, api) => {
  if (event.connection.strategy === && event.stats.logins_count === 1) {
    api.user.setUserMetadata("favorite_color", "blue");


1 Like

@rueben.tiow thanks for your help.

Unfortunately, this does not solve the problem. Imagine I have roleA and roleB and two different signup pages. A signup page for roleA and a separate signup page for roleB. I implemented this using a custom universal login.

This is more convenient for my users and will result in a higher conversion rate compared to offer a selection of the role after the signup.

I would like to write information in the user metadata, so that I can set the role in an action script afterwards.

If I implement your solution, then all users get the same role.

Hi @ArkasDev,

Thanks for the reply.

If you need to set the Role of a Social user preemptively, it won’t be possible until they have signed up (have a user profile).

Because of this, you won’t be able to update the user_metadata because the user will not have been created yet.

So with that in mind, you will only be able to set the Role of the Social user after they have signed up to your app.

Could you please confirm if there are any distinctions between a user that belongs in Role A versus Role B?


Hi @rueben.tiow,

oh that’s bad news. There is a big difference between the roles. It is a platform where Twitch streamers and their community users can interact with each other. I only provide sign in using Twitch social.

  1. I would like to create two different sign in pages, so that I can better promote the value for the individual role.

  2. I don’t want to show the community users the ability to assign the role of a streamer after they sign up.

  3. The onboarding of a streamer is different from that of a community user. Additional data is required, and a streamer is only accepted after a manual check.

  4. If I cannot pass user_metadata, how can I implement something like an invitation link? When a user signs in, I want to save if he was invited by another user. This could also be implemented using user_metadata.

It feels like inconvenient if this entire flow starts after the user signs in. There are many other two-sided platforms that also set the role assignment the way I prefer.


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