Connecting to MS Graph from Forge

This is probably a very basic question, but I’m having trouble figuring out how to connect to the MS Graph API from Forge. MS Graph is a RESTful API which lets you access things like Outlook Calendar events, emails etc. For example, to get all my calendar events this month, I call this endpoint:

GET https://graph.microsoft.com/me/calendarView?startDateTime=2023-03-01T09:00:00.0000000&endDateTime=2023-03-31T17:00:00.0000000

I’ve set up the MS Graph app and got an application ID and secret, as well as OAuth 2.0 authorization and token endpoints. I just can’t figure out what I’m supposed to do with them in Forge.

I tried following this page on the runtime API: https://developer.atlassian.com/platform/forge/use-an-external-oauth-2.0-api-with-fetch/ which uses the Google console as an example, but I don’t know how to apply it to Microsoft Graph instead of Google Console.

For example, it says to set up the following in manifest.yml:

providers:
  auth:
    - key: google
      name: Google
      scopes:
        - 'profile'
        - 'https://www.googleapis.com/auth/userinfo.email'
      type: oauth2
      clientId: PLACEHOLDER
      remotes:
        - google-apis
      bearerMethod: authorization-header
      actions:
        authorization:
          remote: google-account
          path: /o/oauth2/v2/auth
        exchange:
          remote: google-oauth
          path: /token
        revokeToken:
          remote: google-oauth
          path: /revoke
        retrieveProfile:
          remote: google-apis
          path: /userinfo/v2/me
          resolvers:
            id: id
            displayName: email
            avatarUrl: picture
remotes:
  - key: google-apis
    baseUrl: https://www.googleapis.com
  - key: google-account
    baseUrl: https://accounts.google.com
  - key: google-oauth
    baseUrl: https://oauth2.googleapis.com
permissions:
  external:
    fetch:
      backend:
        - 'https://www.googleapis.com'
        - 'https://oauth2.googleapis.com'
        - 'https://accounts.google.com'
function:
  - key: main
    handler: index.run
    providers:
      auth:
        - google

but I don’t know which parts I need to change or what to change them to. Like, obviously key: google and name: Google need to change, but is there something specific I need to change them to, or can I just use any values I like? Likewise, remotes: - google-apis - can I just change that to remotes: - msgraph-apis or is there a specific value it needs to take for MS Graph?

Thanks for any help!

1 Like