derptacious
02/08/2023, 7:10 AMrp_st
02/08/2023, 7:18 AMts
let userId = session.getAccessTokenPayload().impersonationId;
if (userId === undefined) {
userId = session.getUserId();
}
And then when you want to start an impersonation, you can update the current session like this:
ts
await session.mergeIntoAccessTokenPayload({
impersonationId: "..."
});
And then to stop an impersonation, you can do this:
ts
await session.mergeIntoAccessTokenPayload({
impersonationId: null // this will remove this key from the access token payload
});