I am working on a Forge app with a Custom UI and need to retrieve the Forge token (or any relevant authentication token) from the app. The goal is to use this token in our backend to securely access Jira assets.
I have reviewed the Forge Bridge libraries and explored methods like requestJira
and view.getContext()
, but so far, I haven’t been able to extract or reuse the token in the backend.
Could someone guide me on the following:
- How to retrieve the Forge token or any relevant authentication token from the Custom UI or Resolver.
- How to securely use this token in a backend system to access Jira assets.
Here is the code I’ve tried so far:
Resolver Code:
resolver.define("sampleAPI", async ({ context, payload }) => {
// Attempt to retrieve a token or authentication information
const forgeToken = context?.token || 'No token found';
console.log("Forge Token:", forgeToken); // Output: No token
});
Custom UI Code:
import { events, invoke, requestJira, view } from "@forge/bridge";
// Attempt to get context
view.getContext().then((context) => {
console.log("Jira Context Token:", context); // Output: No token
});
So far, I’ve been unable to retrieve the token using these methods. Any advice, examples, or best practices would be greatly appreciated.