Using auth0 management SDK

Hi
I am using gopkg.in/auth0.v5/management
In my go-lang api I need to use management api.

because I need to check the user details

I am trying to use the sdk for this api , here I need the token

domain + “/api/v2/users-by-email?email=” + ctxUser.Email

i tried the following code

   txUser := impart.GetCtxUser(ctx)
  
   m, err := management.New(domain, management.WithClientCredentials(clientid, clientsecret))
	res2B, _ := json.Marshal(m)
	if err != nil {
		// handle err
	}


         existingUsers, err := m.User.ListByEmail(ctxUser.Email)
	if err != nil {
		// handle err
	}

         if len(existingUsers) == 0 {
		return
	}

here I am getting len(existingUsers )=0 but user is exist in auth0 server

I need to get the corresponding user details

Unsure if it’s what explains the outcome you’re experiencing, but one thing to have in mind is that the endpoint in question looks for an exact match to the provided email address and is case-sensitive. Is it possible that the email you’re searching for and the one in the service differs by the case?

1 Like

Hi @jmangelo

Thank you for replaying.

emails are same.

while using this api call

domain + “/api/v2/users-by-email?email=” + ctxUser.Email

I am getting the correct details of the user.

I want to fetch the auth0 user details using golang code

so I find out we can use the management SDK. but using the SDK its not returning anything, even not creating the token

or

if I use api instead of using sdk. How can I get the token through code.

My requirement is that, I want to fetch the auth0user details of a specific email using golang.

this is what I am saying

but I dint get how can I get ‘YOUR_MGMT_API_ACCESS_TOKEN’ in my goland code.

I tried to use SDK for this purpose, but I didn’t get the output management.New() function is returning nil

The access token should be obtained by the SDK when you initialize it with management.WithClientCredentials(clientid, clientsecret). Have you confirmed that you’re passing the correct values for client ID and secret? In addition, have you authorized the client to be able to obtain a Management API access tokens with the necessary scopes?

2 Likes

Thanks for helping on this one Joao!