Can we use any api/endpoint provided by Auth0 to create user based on email id and token

Hi Auth0 Team,

I have a question.

I would like to know if we have an existing Auth0 api or a sample code to be able to create a user based on user details[like email id, first name, last name, address] and token similar to how it is done in case of Single Sign on with Google.

I am currently receiving a http response from Google which has above user details and token for a piece of code that I am working on.

I did see that there is a Sign in with Google UI and toggle available for that on Auth0 dashboard. However, I would like to achieve user creation purely from code/api without showing the UI (Auth0 login screen)

Hi @harpreet.kaur,

Yes, you can create users with the management API create users endpoint:

https://auth0.com/docs/api/management/v2/users/post-users#endpoint

Hi Dan,

Thank you for the response. However, the page of the documentation that you pointed me to has user creation basis the username and password and not purely the email id and token. I examined the body of api request. It contains the password parameter which I don’t have.

So my use case is that I am using “Subscribe with Google” flow in my application and the “Google apis” provide a response that includes the user information as well as a unique token that identifies the user and with these two pieces of information I would like to create the user. I would like to know if somehow I could use the token.

Further, I know Auth0 has subscribe with Google functionality available in its login form. However, I do not want to use the Auth0’s login form for that but purely the apis

When I further clicked on the link passwordless

Then I got below page which talks just about login through 3 different methods and not about registering a new user using Auth0 as you can see in the image below

I am not sure if I am missing something here. Could you please clarify.

@harpreet.kaur,

Sorry, I missed the bit about google in your original post. You can’t create a social user with an upstream IdP (i.e. google). You need that user’s permission and need to have them log in via the google login prompt to have the profile added to Auth0.

Now, it’s possible to avoid the Auth0 prompt and direct them straight to the IdP by passing a connection param with the request to authorize. This may give you the desired login experience.

Then, if you want to access the user’s google tokens to interact with the API, you can get them in the user’s profile from the auth0 management API, here.

Thank you Dan for the explanation.
However, my question is slightly different.

For the point below where you are asking us to direct to IDP to give the consent.

“Now, it’s possible to avoid the Auth0 prompt and direct them straight to the IdP by passing a connection param with the request to authorize. This may give you the desired login experience.”

When I stated that I have the user information and the id token. By this time my app also has user’s consent.
The catch however is that I am using Auth0 create the user for me(and then auth0 id provided is then saved in my application’s database via the apis ) and so how do I indicate to Auth0 that I have the user consent and that the user is verified.

Because in the case where we use Auth0 login form with Social login embedded, the sharing of the tokens between google and auth0 takes place directly but not in the above stated case

Or does that mean I need to ask for the consent again(since I stated I already have the consent) and will the below piece of code show a consent screen or will the consent be obtained programmatically?

Regards,
Harpreet

Typically, Auth0 is going to act as the service provider and will broker the transaction with the identity provider (google).

Auth0 can’t set up an auth session based off of an id token, and has no context from google about the user.

Basically you are saying id token can’t be used.

So if I use webAuth will the consent be obtained behind the scenes via the apis or will webAuth.authorize trigger a UI screen where the consent etc would be asked for.

The user needs to consent, i.e. they need to see a consent screen.

Is there a reason why this use case is working around the normal flow? It seems like a very complicated way to get to the same end.

Hi Dan,

So the use case is that the end user paid for a product using subscribe with google but this is their first time on the website where subscribe with Google option is used and when the user pays through Google then my website receives the user information and the purchase information because the subscribe with google option was embedded on my website. But obviously I do not have the password and using these two pieces of information I would like their account to be created and the purchase information to be stored. However Google also provides a ui for account creation but we can custom code the account creation logic so was thinking if I could achieve this through the code alone and by this time my website already has the consent from the user to access their purchase and profile information. And I would like to pass this information to Auth0 for account creation as my website is using Auth0 to achieve account creation.

Please also note that the use information also has some toke.

Currently, on Auth0 how do you create account if the user signs up with Google using the Google sign up enabled on the registration /login form because Google does not share the user password. Maybe sharing some profile information and access token. Whatever you achieve through UI can we do that using code by sharing info via the backend.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.