Set user_metadata on postRegistration using actions

Hey everyone,

I need to generate an API key on another service when the user registers, so I am using Actions, this part works perfectly and I’m able to get the api key.

The next step is to store the key in the user_metadata. I have tried using the Management API according to this post here. But my website being a SPA. I have an error which is :

{
  "message": "{\"error\":\"unauthorized_client\",\"error_description\":\"Grant type 'client_credentials' not allowed for the client.\",\"error_uri\":\"https://auth0.com/docs/clients/client-grant-types\"}",
  "name": "unauthorized_client"
}

I have looked up the documentation (the one linked in the error and this one) but I couldn’t find a way to programmatically generate an API token.

Can anyone help me there ?

Thanks,

Benjamin

If someone has an idea to solve the problem that would be great

Hi @benjamin.soulas
Thanks for contacting us at Auth0 Community. apologies for the delay on this one.

You can update user metadata in actions via the following method:

api.user.setUserMetadata(‘foo’, 123);

I would use the Pre-User Registration action as the API object is available here.

I hope this helps.
Regards

1 Like

Hey there!

As this topic is related to Actions and Rules & Hooks are being deprecated soon in favor of Actions, I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!