How to force new users to create a username if they registered with Google OAuth?

Hi, I have been reading docs for days with no luck. I’m extremely confused and any help is massively appreciated.

I created a Vue 3 app with an Auth0 integration that allows users to login in two ways: a normal database login that requires a username and password, and Google OAuth.

The problem is that I can’t figure out how to require the Google OAuth users to create a username immediately upon registering. This is a problem because my app has user generated content and the email cannot be visible to other users - a normal username is required for all new users. I’ve been reading a lot of docs about actions and writing custom claims to the JWT, but it feels like I’m going in the wrong direction.

In my app, I can easily see the logged in user’s information after successfully following the quick start guide for Vue 3 (Auth0 Vue SDK Quickstarts: Calling an API). My approach was to check if the authenticated user had a username in their custom claims, then if they don’t have one, prompt them to create a username. But this is where I got stuck - do I need to call the Auth0 management API to do this? if so, how?

Any help is appreciated.

To clarify, this is what I’m trying to achieve:

  • Have the username in the JWT for all users
  • Avoid storing any emails in my database, and just allow users to be identified by username only, while Auth0 maintains knowledge of which emails are associated with the usernames

It seemed like using an action was the wrong approach because actions can only be triggered after routine login events, whereas I was looking for more of a special event just to create a username for an existing user.

I’ve come to the conclusion that there’s no way to avoid storing emails along with the rest of my application data for the Google OAuth users.

1 Like

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