Auth0 Home Blog Docs

Custom Database: Can we store social signups in custom database

custom-database

#1

Hi,
Currently, I am exploring Auth0 and planning to use custom database. So I configured my create script accordingly to store user information in my database. I tried with regular user with username/password it stored that user into my custom database and then i tried with social login that did not create an entry in my database. Is that possible, if yes, Can somebody point me in the right direction to achieve this?

Thanks in Advance


#2

Can someone guide me here?


#3

Hey @juju20ac,

Custom databases are only available for username/password connections. The same technique does not work for social, enterprise or passwordless connections.

Why do you need those profiles to be stored in your database? If we know your use case, more people might be able to help you out and point you in the right direction.


#4

Hi there,
Thanks for your response. we have some live dashboards where we need to join our data with user profiles to provide our insights to our users and some business insights to our executive. It will be easy to join if we have the user profile data in our database as soon as they signup.

Please let me know if you need more details

Note: we are not planning to store their social creds. We just need to store their basic profile in our database and so on.
Thanks,


#5

Hi @ thijmen96 , Do you have any suggestions for me? please let me know if you need additional information.
Thanks,
J


#6

Sorry for the late response, didn’t mean to leave you hanging! I’d say there are three ways to go:

  1. When a user logs in, normally you’d find their user ID in your database. So, in the rare case you don’t (read: they’re a new user), use the data in the ID token to add them to your database

    • Or, as a slightly different way of doing this, if you don’t find them in your database, make a call to the Management API with the user ID from the access token and add the user to your database
  2. Don’t store any user info in your database and always use a server side Management API call to retrieve it

  3. Create a rule in Auth0 that, on first login, contacts your application server and tells it what data it needs to add to the database. That way, once all the rules are run and the user is redirected to your app, the info is already in the database

I think those are your best ways to go, as they require the least amount of work and can be invisible to your user and the front-end application (I’m assuming you’re talking about a SPA with an API, but it would work basically the same for a regular web application).


#7

@juju20ac

Can you show me how you store the user info in your database? I had to create an endpoint at the end to do it in the backend but the connection is not forming still.

Where do you make the connection? Do you store the user info when user signs up?