Hi,
I’m using a custom authentication method for my Mongo Realm application.
I created a collection to store custom user data and mapped User ID field to my user collection.
I created a function to update custom user data collection and associated it in a trigger that runs when authentication happens.
I’m receiving acess_token when I authenticate, but when I try to get user context (using the access_token I received) it is OUT DATED.
I know that the function to update custom user data using a trigger run asynchronously as stated here: https://www.mongodb.com/docs/atlas/app-services/users/custom-metadata/
But when I authenticate a user I want an ‘access_token’ that provides me updated information about logged user.
Access token is built based on custom user data information, and the access_token I’m receiving doesn’t provide me the ‘context.user’ information I want, because the trigger is still running.
When I authenticate again I receive a valid access_token (Way bigger than the first one), that shows me updated informatiou about logged user.
I’m using an endpoint to login:
https://realm.mongodb.com/api/client/v2.0/app/<MY_APP_ID>/auth/providers/custom-function/login
And I’m using another endpoing to debug:
https://sa-east-1.aws.data.mongodb-api.com/app/<MY_APP_ID>/endpoint/debug
This debug endpoint just returns context.user information.
To use debug endpoint I need to use ‘access_token’ provided on authentication as a bearer token to access my API.
Thx for your help,
Carlos Emílio