Is it possible to perform external oauth in forge app ? with custom oauth provider?

In my case I gonna perform Surveysparrow oauth to get access token from surveysparrow .
I guess External oauth here we have no docs for to perform external oauth like surveysparrow .

Actually i have client id and client secrets from surveysparrow and i can able to configure redirection url for oauth in surveysparrow .

Is it possible to perform oauth from external provider like surveysparrow ? .

I tried by manually hitting these surveysparrow oauth url . The problem i am facing here is the redirection url . My forge app in project page location so the url is like

https://peterparker1729.atlassian.net/jira/software/projects/SCRUM/apps/848a27cf-010b-4e41-8979-8fb5c994b73c/2eafa8f9-306e-4ea3-befc-37680e35a86d

so it have some dynamic values like project key in the above url . Form surveysparrow side they are allowing only single redirection url for oauth and it should be static .

FYI not able to share docs for surveysparrow oauth here its getting detected as spam :cold_sweat:

can anyone please help on this case is it possible ?

Thanks in advance :pray:

1 Like

Is this what you are looking for? https://developer.atlassian.com/platform/forge/manifest-reference/providers/

Yes @rmassaioli . Thanks
I have tried External oauth for Surveysparrow . but getting this error .

FYI adding My manifest here ,

permissions:
  scopes:
    - read:jira-work
    - write:jira-work
    - storage:app
  external:
    fetch:
      backend:
        - 'https://app.surveysparrow.com'
        - 'https://api.surveysparrow.com'
        - 'https://www.googleapis.com'
        - 'https://oauth2.googleapis.com'
        - 'https://accounts.google.com'
    images:
      - "https://appnest-app.salesparrow.com/SurveyMigrationTest-4119/version_1.0/icon/Color.png"
      - "https://atlassian.design/static/LockClosed-c651d828718647b03f5d4799d705b7e39d1ead63004aca3617049d3f1c0bb357.png"
      - "https://static.surveysparrow.com/site/assets/integrations/inner/microsoft/v2/create-and-share-chat-surveys-directly-from-teams.png"
      - "https://developer.atlassian.com//console/assets/assets/SearchNoResults.ae017adfe3f389e4be72.svg"

providers:
  auth:
    - key: surveysparrow
      name: SurveySparrow
      scopes:
        - view_contacts
      clientId: ${SURVEYSPARROW_CLIENT_ID}
      type: oauth2
      remotes:
        - surveysparrow-api
      bearerMethod: authorization-header
      actions:
        authorization:
          remote: surveysparrow-api
          path: /o/oauth/auth
          queryParameters:
            response_type: code
        exchange:
          remote: surveysparrow-api
          path: /o/oauth/token
        retrieveProfile:
          remote: surveysparrow-api
          path: /api/v1/users/me
          resolvers:
            id: id
            displayName: name
            avatarUrl: avatar_url

modules:
  jira:projectPage:
    - key: seosparrow-hello-world-project-page
      resource: main
      resolver:
        function: resolver
      render: native
      title: "Surveysparrow"
      layout: basic
  function:
    - key: resolver
      handler: index.handler
    - key: event-handler
      handler: eventHandler.handler
    - key: create-ticket-handler
      handler: createTicket.handler
    - key: main
      handler: oauth.handler
      providers:
        auth:
          - surveysparrow
    - key: oauth-handler
      handler: oauth.handler
  trigger:
    - key: issue-created-trigger
      function: event-handler
      events:
        - avi:jira:created:issue
    - key: issue-updated-trigger
      function: event-handler
      events:
        - avi:jira:updated:issue
    - key: issue-deleted-trigger
      function: event-handler
      events:
        - avi:jira:deleted:issue
    - key: task-created-trigger
      function: event-handler
      events:
        - avi:jira:created:task
    - key: task-updated-trigger
      function: event-handler
      events:
        - avi:jira:updated:task
    - key: story-created-trigger
      function: event-handler
      events:
        - avi:jira:created:story
    - key: story-updated-trigger
      function: event-handler
      events:
        - avi:jira:updated:story
  webtrigger:
    - key: create-ticket-webtrigger
      function: create-ticket-handler
    - key: oauth-callback
      function: main

resources:
  - key: main
    path: src/frontend/index.jsx
  - key: logo
    path: src/assets

app:
  id: ari:cloud:ecosystem::app/848a27cf-010b-4e41-8979-8fb5c994b73c
  runtime:
    name: nodejs20.x

remotes:
  - key: surveysparrow-api
    baseUrl: https://api.surveysparrow.com
  - key: google-apis
    baseUrl: https://www.googleapis.com
  - key: google-account
    baseUrl: https://accounts.google.com
  - key: google-oauth
    baseUrl: https://oauth2.googleapis.com

and Handler

resolver.define('initSurveySparrowAuth', async () => {
  try {
    const surveySparrow = api.asUser().withProvider('surveysparrow');
    if (!await surveySparrow.hasCredentials()) {
      const authUrl = await surveySparrow.requestCredentials();
      return { success: true, authUrl };
    }
    return { success: true, authenticated: true };
  } catch (error) {
    console.error('Auth initialization error:', error);
    throw error;
  }
});
Error: Bad provider or missing config for provider surveysparrow
    at findExternalAuthProviderConfigOrThrow (webpack://jira-project-page-ui-kit-2/node_modules/@forge/api/out/api/fetch.js:70:1)
    at buildExternalAuthAccountsInfo (webpack://jira-project-page-ui-kit-2/node_modules/@forge/api/out/api/fetch.js:110:1)
    at Object.withProvider (webpack://jira-project-page-ui-kit-2/node_modules/@forge/api/out/api/fetch.js:138:1)
    at <anonymous> (webpack://jira-project-page-ui-kit-2/src/resolvers/index.js:7:1)
    at Object.resolve (webpack://jira-project-page-ui-kit-2/node_modules/@forge/resolver/out/index.js:55:1)
    at /private/tmp/forge-tunnel-80291-UGP1SsglA3xI/index.cjs:2:563395
    at Q (/private/tmp/forge-tunnel-80291-UGP1SsglA3xI/index.cjs:2:563401)
    at new Promise (<anonymous>)
    at /private/tmp/forge-tunnel-80291-UGP1SsglA3xI/index.cjs:2:563158
    at AsyncLocalStorage.run (node:async_hooks:338:14)

can you please help me to resolve this :pray:

is there any generic url to navigate to an app inside my account like ?
https://id.atlassian.com/outboundAuth/finish?appId={app_id}&token={toke} . . Even this also fine in this case . please help . Thanks in advance :pray: