How to get forge token from the app custom UI or Resolver

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:

  1. How to retrieve the Forge token or any relevant authentication token from the Custom UI or Resolver.
  2. 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.

It sounds like you are looking for Forge remote. Specifically, this page details how you would use a token to call Atlassian APIs from your backend.

Thank you for your response. I have checked the page you shared and had previously reviewed it as part of exploring Forge Remote. While it provides useful details about calling Atlassian APIs from a backend using a user token, that approach requires the user token for remote access, which isn’t exactly what I’m looking for.

What I’m trying to achieve is different: I want to retrieve the iframe Forge token within the Custom UI, send it to an external backend, and reuse it there to access Jira APIs. My goal is to leverage this token directly, rather than relying on user tokens or OAuth mechanisms.

If there’s a way to retrieve the iframe Forge token from the Custom UI and use it securely in the backend for Jira API access, I would appreciate further guidance or any relevant documentation.