Auth0 Home Blog Docs

Types of `user_id` allowed?

user_id
managment-api-v2

#1

I seem to be able to create Users via the management API that I can not retrive.
user_ids like CK10596 and u22759of6c92c seem to work fine. But I also have uids like email@example.com.

If I want to create a User with the user_id email@example.comtwice I get an “400: The user already exists” on the second try - which is correct.
But If I then try to get the user via /api/v2/users/email@example.com I get a “404: The user does not exist.” - so I wonder if I’, there is an API limitation or just encoding issues in the Python Library I use.

Pseudo code is like this:

payload = {
    "connection": 'DefaultDatabase',
    "email": credential.email,
    "password": credential.secret,
    "user_id": credential.uid,
}
try:
    newuser = auth0api.users.create(payload)
except Auth0Error as ex:
    if ex.status_code == 400 and ex.message == u'The user already exists.':
        try:
            newuser = auth0api.users.get('auth0|{}'.format(credential.uid))
        except Auth0Error as ex:
            if ex.status_code == 404 and ex.message == u'The user does not exist. ':
                # WTF? First we get told it does exist
                # then they complain it does not?
                return

#2

I think it’s an issue with the Python Library. See https://github.com/auth0/auth0-python/pull/87.


#3

But this still seems not to be the (only) issue.

I still have instances where auth0api.users.create({'connection': 'DefaultDatabase', 'user_id': u'CK10001', …}) fails with 400: The user already exists.

But auth0api.users.get('auth0|CK10001') fails with 404: The user does not exist..

Is there any way to do a “get or insert” or make auth0api.users.create() return the conflicting user?


#4

The issue is that all users need to have different E-Mail Addresses. See https://community.auth0.com/questions/1012/multiple-usernames-with-the-same-email-in-one-conn


#5