Seperate connection for GET user by email

We have duplicate email addresses in auth0, separated by connection. Username-Password-Connection and staging-users-only. We did that to have easier access to both environments for the business. The issue: Both users are in the response, and adding the connection to the fetch options does not work - it can’t be separated through the mgmt api and I want to seperate the workflow. The goal is to get the user_id for the user of a specific connection, the main Username-Password-Connection.

Is there any way a add the connection to the request options?

const options = {
    method: 'GET',
    headers: {
      authorization: `Bearer ${accessToken}`,
     connection: 'Username-Password-Connection",
      'content-type': 'application/json'
    }

Solution: Use query parameters:

const response: unknown = await ofetch(`${process.env.AUTH0_URL}/users?q=email:"${primaryMail}" AND identities.connection:"Username-Password-Authentication"&search_engine=v3`, options)
    console.log(response)

documentation: Auth0 Management API v2

1 Like

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