Auth0 Home Blog Docs

Example of Saving the user_Id in application database

user-creation
user-profile

#1

I have added Auth0 to my application and am following the docs for the single page applications (Angular2). After user logs in, I fetch the profile by invoking auth0.client.userInfo with scope: ‘openid profile’. There is no user_id in that profile object. I want to store the user_id in my application and associate it with other data. I want this user id to serve as a key for fetching data from other tables in my app. Is there an example demonstrating something similar?


#2

Hi, the closest I found was guidance from https://stackoverflow.com/questions/51795272/auth0-create-user-in-local-database-after-auth0-sign-up.

I chose to go with the first approach of creating a Pre User Registration Hook that will send a POST request to my database, then store my own user ID in Auth0’s user_metadata. Then, whenever I get the profile from Auth0 after a user logs in, I already have my own app’s ID.