Searching for Users by External Identity Provider ID
Last Updated:
Overview
This article explains how the user search can be used to find users by their external identity provider ID value. If the user_id is the secondary identity in the identities array, is there a way to search for a user with that value as well?
This specific "user_id" value is found in the "identities" array of the user object:
"identities": [
{
"provider": "google-oauth2",
"user_id": "1234567890",
"connection": "google-oauth2",
"isSocial": true
},
{
"profileData": {
"email_verified": false,
"email": "test.user@auth0.com"
},
"provider": "facebook",
"user_id": "abcdefg",
"connection": "facebook",
"isSocial": false
}
],Applies To
- Search Users
- External User ID
Solution
This user search query will be able to return a user through an external user_id: api/v2/users?q=identities.user_id="{external_user_id}"
Note that the each identity will be searched, so for the linked account example above in the Overview section, both api/v2/users?q=identities.user_id="1234567890", and api/v2/users?q=identities.user_id="abcdefg" will return the same user profile.