asUser in async event function

Hi.

I’m using the async events API. When I push an event to a queue, like so:

await queue.push({ "hello": "world" });

can I somehow make the event inherit the current user context?

Inside the event, I want to use

await api.asUser().requestConfluence(…)

but that always fails. asApp works just fine.

When I log the context parameter in the resolver, I see that there’s an account ID field, but it’s always undefined:

{
    installContext: 'ari:cloud:confluence::site/102f9718-17d8-11ed-861d-0242ac120002',
    accountId: undefined,
    license: undefined,
    jobId: 'page#1b50a3d0-17d8-11ed-861d-0242ac120002'
}

Any help would be appreciated.

Best regards,
Maximilian

2 Likes

Hi @maximilian,
Sorry, that isn’t possible today. Only functions that are directly invoked by the user will contain the user context and therefor have the ability to utilise the asUser API function call. This means that webtriggers, scheduled triggers, product events and asynch events are restricted to asApp api calls only.
My team has been exploring introducing this feature for product events, but not yet asynch events.
I have raised [FRGE-805] - Ecosystem Jira for this based on your above feedback. Feel free to add any additional comments/feedback to this ticket in what you would like to see here.
Cheers,
Sam.

1 Like

Hi @SamPurchase,

Thank you for the quick reply and for raising the Jira issue.

Best regards,
Maximilian

1 Like

Hi, is there any update on this? It would be super great if we could call asUser through Forge Async event.

1 Like

Same question, is there any news around? asApp currently doesn’t support withProvider method to perform external auth for GDrive, for example on Async API. So, I have a kinda blocker here.

It’s possible to create some strange workaround by changing entity status flags, notifying the front-end part, and adding logic to “resend direct action request” from FE, once the status is updated to “I need to make a call to external API”, but it feels like the kinda wrong way of interaction.

1 Like

You can watch and vote for this ticket: [ROADMAP-48] - Backend User Impersonation

1 Like