Auth0 Home Blog Docs

Change email/username react native

react-native

#1

I’m looking through the react-native docs here: http://auth0.github.io/react-native-auth0/Auth.html#.userInfo

And it doesn’t look like there is a way to have a user change their email/username and password. I can’t tell if maybe its the .patchUser(), however, that only includes user_metadata and if you follow the link to the base api docs, https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id, user_metadata is clearly separate from the email field.

In addition, when I try to use the endpoint, I get auth0.auth.patchUser and auth0.users.patchUser is not a function.

Anyone know whats going on with the react-native documentation?


#2

The only user property that you would be able to update from any native (or SPA) application is the user_metadata. This is not a limitation of the React Native SDK, but of the way Management API v2 permissions work: a user can only update their own user_metadata, nothing more.

All the other updatable properties for the user can only be updated with a token obtained through the Client Credentials grant, available only for non-interactive or regular web app clients (i.e. clients that can securely keep a secret). This means that you will have to:

  • Have a backend API for your React Native application that will handle the email/password changes
  • Have your React-Native app invoke your backend API for the requested changes
  • Define a new application type (of type “non-interactive”) representing the backend API. Grant this application permissions to invoke the Auth0 Management API v2 with update:users permission.
  • Have your backend API obtain a token using the client_id and client_secret of the authorized non-interactive application.
  • With that token, have the backend API make a request to https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id to update the desired properties.