Off the cuff that sounds like data that you would not want to include in the token. So your process will be:
- User logs in
- Rules run possibly adding custom claims to token
- App grabs
user_id
fromsub
and uses that to query the DB
If that is what you are doing but it’s not working we’ll need to get more info. When you say it is not retrieving the correct id, is it retrieving the wrong one? Or none at all? Can you add some logging to show what is happening?