# Login from custom API?

**URL:** <https://community.auth0.com/t/login-from-custom-api/45460>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [June 29, 2020, 2:29pm UTC](https://community.auth0.com/t/login-from-custom-api/45460 "2020-06-29T14:29:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![noyo87](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/noyo87/32/12776_2.png) [@noyo87](https://community.auth0.com/u/noyo87)\
**Post date:** [June 29, 2020, 2:29pm UTC](https://community.auth0.com/t/login-from-custom-api/45460/1 "2020-06-29T14:29:41Z")

</div>

Hello!  
My app is a backend api (go) + SPA.  
We had to implement a custom sign-up process because we wanted additional restrictions on usernames (number of characters, allowed characters). This is done using the management api from our go backend.  
Now, I’m trying to have the user automatically logged-in once he successfully created his account.  
Ideally, the authentication token would be returned as part of the sign-up api.  
What is the right authentication flow to use and auth0 api endpoint?

Thanks you!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 30, 2020, 7:18pm UTC](https://community.auth0.com/t/login-from-custom-api/45460/3 "2020-06-30T19:18:35Z")

</div>

Hi @noyo87,

You can use the [resource owner password grant](https://auth0.com/docs/api-auth/tutorials/password-grant) to exchange a user’s email/username and password directly for a token. This grant type is for confidential clients, so the exchange should be implemented on your backend.

The automatic login flow (token exchange) of a newly registered user is discussed in this thread here:

> [@Silent Auto-Login for User after Completing 'Authentication API'-Backed Custom Signup Form](http://community.auth0.com/t/silent-auto-login-for-user-after-completing-authentication-api-backed-custom-signup-form/29790):
>
> I currently have a web application that is secured with Auth0 via a Regular Web Application. The Auth0 Application uses a standard credentialed Universal Login form for user authentication, with a Database Connection. For user registrations, I have a custom signup form written in C# that uses the .NET Auth0 SDK. It creates a new Auth0 user in the Database Connection via the Management API. I’m trying to add the ability for the custom signup form to redirect the user to my secured web applicati…

---

<div class="post-metadata">

**Author:** ![noyo87](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/noyo87/32/12776_2.png) [@noyo87](https://community.auth0.com/u/noyo87)\
**Post date:** [June 30, 2020, 11:07pm UTC](https://community.auth0.com/t/login-from-custom-api/45460/4 "2020-06-30T23:07:59Z")

</div>

Thanks @dan.woda ! It absolutely answers my question.

However I think I found an other possible solution. Do you think we could use Pre-User Registration Hook to implement username validation ? [Pre-User Registration](https://auth0.com/docs/hooks/extensibility-points/pre-user-registration)  
This way we would get rid of our own registration system and handle this directly from the universal login.  
Would that work to you? What is the best solution to you?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 1, 2020, 9:51pm UTC](https://community.auth0.com/t/login-from-custom-api/45460/5 "2020-07-01T21:51:49Z")

</div>

Hi @noyo87,

Looks like this was resolved in a support topic.

From the topic:

> Yes, you are correct. You could just use the hook to make a decision about what a valid username is. That would be a much better solution and would save you a lot of time, and give you the advantages of using new universal login (you’ll have to use the new universal login if you want to propagate an error from the hook to the user).

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [July 16, 2020, 9:51pm UTC](https://community.auth0.com/t/login-from-custom-api/45460/6 "2020-07-16T21:51:53Z")

</div>

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