How can we get access token from the providers after External OAuth 2.O

Is there any way to get the access token from the forge application. I have successfully implemented the external OAuth 2.O, but I can’t see the access token, Is it store anywhere ?

resolver.define("callGoToAPI", async (req) => {
  console.log("req--", req);
  try {
    const gtResolve = await api
      .asUser()
      .withProvider("gotoresolve", "resolve-profile");
    if (!(await gtResolve.hasCredentials())) {
      const credData = await gtResolve.requestCredentials();
      console.log("credData", credData);
    }

    const response = await gtResolve.fetch("/admin/rest/v1/me");

    if (response) {
      return response.json();
    }

    return null;
  } catch (err) {
    console.log("err", err);
    throw err;
  }
});

I’ve selected Custom UI and Issue-context template.
Could you please help me ?

1 Like

Once a user is authenticated, the fetch method automatically includes their authentication token for each request. You don’t need access to the access token.

https://developer.atlassian.com/platform/forge/runtime-reference/external-fetch-api/

2 Likes

Thanks @AdamMoore for the response. Actually I need to send the access_token inside body for a particular request to get some external data through webhooks using body params.

{"customerName":"Bob","sessionType":"Attended","supportType":"Desktop",
  "webhooks": [
    {
      "targetUrl": "https://enz9uldblqnt.x.pipedream.net/",
      "accessToken" : <access_token>
      "type": "ChatMessage"
    }
  ]
}