Hi, I want to check if a user with the currently processing email address exists in a different connection in the tenant, when in a post login action script,. The goal here is to grab a piece of info (app_metadata) from that user if it exists, and copy it over to the user record just created by auth0 in the current connection.
Is this possible?
Hey there @auth0rocks welcome to the community (sweet username )!
This will involve using the Management API to search for the user’s email at which point I believe you’d have the information you need.
Here’s some info on how to use the Management API in Actions:
https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947
And on caching tokens in Actions:
https://community.auth0.com/t/caching-management-api-access-tokens-in-login-action/95855
Hope this helps!
1 Like
Thanks! Indeed I found a way to do this vai sth like this
const ManagementClient = require('auth0').ManagementClient;
const management = new ManagementClient({
domain: event.secrets.domain,
clientId: event.secrets.clientId,
clientSecret: event.secrets.clientSecret,
});
const userRecords = await management.getUsersByEmail(event.user.email);
thanks
1 Like
Great! Thanks for sharing with the community
1 Like
system
Closed
September 1, 2023, 10:50pm
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.