Hi Atlassian teams,
According to the official Forge documentation, the recommended way to get the current user’s accountId
is via request.context.accountId
, like so:
resolver.define('myMethod', ({ context }) => {
const accountId = context.accountId;
});
However, there are situations where you may want to access the accountId
deep inside your application logic — and passing it manually through all method calls can be inconvenient.
One option is to use AsyncLocalStorage
, which lets you access the context anywhere:
contextStorage.getStore()?.accountId;
But I’ve noticed that the @forge/api
package includes an undocumented method:
import { __getRuntime } from '@forge/api/out/api/runtime';
const accountId = __getRuntime().aaid;
This method internally accesses global.__forge_runtime__
.
So my question is:
Is it officially supported to use __getRuntime()
to access aaid
(accountId) in Forge apps?
Or is this an internal API that could be changed or removed without notice?
Would love to hear from Atlassian team members or anyone who has experience with this.
Thanks in advance!