I am using Next.js Universal Login with redirect the users while they are signing up. I use redirection because I want to get additional information about users and send them to my server to store them in my external database. In order to that, I want to get user ID to set a primary key in my database. I could not figure out to get User ID in my redirected page.
I tried to use useUser hook to get the user ID in my redirected page but it gave me an error. How I can do that? Should I get the User ID with ID Token?
First a user open sign up page. Fills email, password. Click continue and redirect to RedirectedPage that I created in Pages folder in Next.js
In this step I want to get additional data from the user like subscription plan, address etc with forms and send REST API request to my server in order to store it in my external database. (Btw, should I do it in Rules or in my Frontend? I read some topics and they said the API Requests should be in Rules due to security reasons.) And also I should get the User ID in this redirected page and send the data together in order to store it. But I could not get the User ID. I also look /api/v1/me, and it didn’t respond as well.
After user fill the forms, click continue and user redirects to continue?state=THE_STATE in order to finish the authenticate.
Did I create the flow wrong? What will be the best practice to send User ID and additional sign up information to my server?
What I’ve learned is that when the user lands on the redirect page, although they don’t yet have a session in the application layer, they are logged into your Auth0 tenant. This means that you can perform silent authentication to get the user’s Auth0 ID.
Alternatively, you can use a post-user registration action to update your system with the Auth0 user ID/email:
I also couldn’t fully understand how I can get the User ID via silent authentication How exactly I can do it?
If the both ways won’t work, Do you know how can I send the user ID right after the user authentication(sign up) on my client side? I think I can use the callback url after user authenticates but it also redirects the callback url after the login process too. So, the User ID is sent at every user login and I don’t desire that.
I’m not sure but I could not find any best practice solution in the documentation for this problem even though it is a common case for applications?