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