How to link app data to auth0 users?

There’s some uncertainty in our company on whether the way we can link app data (foreign keys) to auth0 users has changed very recently.

Our example is the need to store a list of ids for sold products with each seller.
Then we need to query all sellers that have a specific product ID.

Nov 2016 recommendation by auth0 team:

You could store an array of
productID’s in app_metadata (or
user_metadata, please read this doc (inactive link) to
see which would suit). e.g.

//app_metadata
"products": 
  "productX", 
  "productB"
]

You could then query using API v2 users search with the following query:

app_metadata.products:"productB"

This would return all users with productB in their app_metadata.products.

Aug 2017, our working query based on this is:

_exists_:user_metadata.products.product1

Sep 2017 support answer after query stopped working in some tenants

In our multi-stage env, this query stops working in some, not all environments.
The answer to our question about it is:

the query you are trying to do ( _exists_:user_metadata.products.product1) is not supported. This document explains what fields can be used in searching.

Status

I’m copying this here for others that may suffer this problem.
I have a question on valid alternatives outstanding with support and will update here when there are news.

cc: @nico.sabena1 @prashant

1 Like