Forge External with OAuth 2.0 - How to get Auth token to pass as Authorization header

Hello All,

I need to fetch information from our internal system and display in confluence using a macro.

I am able to get profile information by following this example [microsoft forge ]

I need to pass the Authentication token to my API . But the microsoft.listCredentials() method throwing not implemented error.

{
hasCredentials: [AsyncFunction: hasCredentials],
getAccount: [AsyncFunction: getAccount],
requestCredentials: [AsyncFunction (anonymous)],
listCredentials: [Function: throwNotImplementedError],
listAccounts: [AsyncFunction: listAccounts],
asAccount: [Function: asAccount],
fetch: [Function (anonymous)]
}

My manifest.yml

providers:
  auth:
    - key: microsoft
      name: microsoft
      scopes:
        - User.Read
        - offline_access
      type: oauth2
      clientId: *********************
      remotes:
        - microsoft-graph
        - internal-api
      bearerMethod: authorization-header
      actions:
        authorization:
          remote: microsoft-login
          path: /tenant-id/oauth2/v2.0/authorize
        exchange:
          remote: microsoft-login
          path: /tenant-id/oauth2/v2.0/token
          resolvers:
            accessToken: access_token
            accessTokenExpires: expires_in
            refreshToken: refresh_token
        retrieveProfile:
          remote: microsoft-graph
          path: /v1.0/me
          resolvers:
            id: id
            displayName: displayName
remotes:
  - key: microsoft-login
    baseUrl: https://login.microsoftonline.com
  - key: microsoft-graph
    baseUrl: https://graph.microsoft.com
  - key : internal-api
    baseUrl: https://api.myorg.com
permissions:
  external:
    fetch:
      backend:
        - https://login.microsoftonline.com
        - https://graph.microsoft.com
        - https://api.myorg.com

Any help will be greatly appreciated.

Thanks

What is it you want to list the credentials for? To make a call to a given API with a given authentication provider, I would think the other functions would work as in the example. You’d just adjust the API they’re calling.

Hello @AaronCollier , Thank you for your reply.
I tried calling my api from the resolver but getting a 401 error. (FYI Microsoft API returning a 200 )
So trying to find out what went wrong. its might be token issue.

Is there anyway to get the tokens in console ?

Thanks

I don’t know of any way to do that, I would guess for security reasons. Perhaps if you shared how you’re calling the API someone could help you debug :person_shrugging:

Hello @AaronCollier ,
Thanks again for taking time to check this issue .
It might be an issue with the internal tool, checking with the respective team.

Thanks