Hi @BoZhang ,
yes now the error got resolved after adding providers inside handlers . Now I am facing another issue like 401
FYI adding my Manifest here
permissions:
scopes:
- read:app-user-token
- read:app-system-token
- 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'
- 'view_question'
- 'manage_share'
- 'manage_survey_settings'
- 'manage_invite'
- 'view_contact_list'
- 'manage_devices'
- 'view_survey_integrations'
- 'manage_workspace'
- 'view_questions'
- view_reputation_app_platforms
- 'view_workspace'
- 'manage_contacts'
- 'view_invite'
- 'manage_contact_list'
- 'view_user'
- 'view_employees'
- 'view_team'
- 'manage_employees'
- 'manage_user'
- 'view_employee_list'
- 'manage_audit_logs'
- 'manage_employee_list'
- 'view_360_report'
- 'view_survey'
- 'view_targets'
- 'manage_survey'
- 'manage_team'
- 'view_survey_settings'
- 'view_ticket_fields'
- 'manage_question'
- 'view_audit_logs'
- 'view_custom_property'
- 'view_ticket_comments'
- 'view_expressions'
- 'view_tickets'
- 'manage_custom_property'
- 'manage_tickets'
- 'view_theme'
- 'manage_ticket_comments'
- 'manage_survey_share'
- 'create_dashboards'
- 'view_survey_responses'
- 'view_reputation_reviews'
- 'view_webhooks'
- 'view_dashboards'
- 'manage_responses'
- 'manage_webhooks'
clientId: 'cNJMiwtxZkiXLXsywPfStzlLuzPGoHmMBMyLt5rGHC4'
type: oauth2
remotes:
- surveysparrow-api
bearerMethod: authorization-header
actions:
authorization:
remote: surveysparrow-api
path: /o/oauth/auth
queryParameters:
client_id: 'cNJMiwtxZkiXLXsywPfStzlLuzPGoHmMBMyLt5rGHC4'
redirect_uri: 'https://id.atlassian.com/outboundAuth/finish'
scope: 'view_contacts+view_question+manage_share+manage_survey_settings+manage_invite+view_contact_list+manage_devices+view_survey_integrations+manage_workspace+view_questions+view_reputation_app_platforms+view_workspace+manage_contacts+view_invite+manage_contact_list+view_user+view_employees+view_team+manage_employees+manage_user+view_employee_list+manage_audit_logs+manage_employee_list+view_360_report+view_survey+view_targets+manage_survey+manage_team+view_survey_settings+view_ticket_fields+manage_question+view_audit_logs+view_custom_property+view_ticket_comments+view_expressions+view_tickets+manage_custom_property+manage_tickets+view_theme+manage_ticket_comments+manage_survey_share+create_dashboards+view_survey_responses+view_reputation_reviews+view_webhooks+view_dashboards+manage_responses+manage_webhooks'
# 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:customField:
- key: surveysparrow-custom-field
function: custom-field-handler
name: "SurveySparrow Survey"
description: "Links SurveySparrow surveys to Jira issues"
type: "string"
extraAttributes:
projectsActivatable: true
config:
contexts:
- addon_env: general
location: atl.jira.view.issue.right-panel
type: full
displayType: string
jira:issuePanel:
- key: surveysparrow-panel
function: macro-handler
title: "SurveySparrow"
description: "Display SurveySparrow surveys and responses"
icon: https://appnest-app.salesparrow.com/SurveyMigrationTest-4119/version_1.0/icon/Color.png
location: atl.jira.view.issue.right.context
renderMode: dynamic
weight: 100
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
providers:
auth:
- surveysparrow
- key: macro-handler
handler: macro.handler
- key: custom-field-handler
handler: customField.handler
- key: event-handler
handler: eventHandler.handler
- key: create-ticket-handler
handler: createTicket.handler
- key: main
handler: oauth.handler
- 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
auth:
appUserToken:
enabled: true
appSystemToken:
enabled: true
- key: google-apis
baseUrl: https://www.googleapis.com
- key: google-account
baseUrl: https://accounts.google.com
- key: google-oauth
baseUrl: https://oauth2.googleapis.com
Network call response here
{
"data": {
"invokeExtension": {
"success": false,
"response": null,
"contextToken": null,
"errors": [
{
"message": "Needs authentication error",
"extensions": {
"errorType": "USER_CONSENT_REQUIRED",
"statusCode": 400,
"__typename": "InvokeExtensionPayloadErrorExtension",
"fields": {
"authInfoUrl": "https://id.atlassian.com/login?continue=https%3A%2F%2Fid.atlassian.com%2FoutboundAuth%2Fstart%3FcontainerId%3D848a27cf-010b-4e41-8979-8fb5c994b73c_2eafa8f9-306e-4ea3-befc-37680e35a86d%26serviceKey%3Dsurveysparrow%26isAccountBased%3Dtrue%26cloudId%3Dc07acfa1-7518-47a2-9a28-a760d321ecf9%26contextAri%3Dari%253Acloud%253Ajira%253Ac07acfa1-7518-47a2-9a28-a760d321ecf9%253Aworkspace%252F055210fb-6c16-46fa-a6b2-5d5c16b60be6%26redirectTemplate%3DforgeWarning%26appId%3D848a27cf-010b-4e41-8979-8fb5c994b73c&login_hint=peterparkerj1729%40gmail.com&prompt=none&serviceKey=surveysparrow",
"__typename": "InvokeExtensionPayloadErrorExtensionFields"
}
},
"__typename": "MutationError"
}
],
"__typename": "InvokeExtensionResponse"
}
},
"extensions": {
"gateway": {
"request_id": "cc25d22d391a42b3ad2cd10a6b82935a",
"crossRegion": false,
"edgeCrossRegion": false
}
}
}
Handler here
resolver.define('initSurveySparrowAuth', async () => {
const surveySparrow = api.asUser().withProvider('surveysparrow', 'surveysparrow-api');
const isAuthenticated = await surveySparrow.hasCredentials();
console.log(`surveysparrow: ${isAuthenticated}`);
if (!isAuthenticated) {
console.log('before requestCredentials');
try {
await surveySparrow.requestCredentials();
} catch (e) {
console.error(e);
console.error('Failed to request credentials');
throw e;
}
console.log('after requestCredentials');
}
return {
code: 401,
message: 'Failed to get surveysparrow token',
};
});
And the logs from the console
INFO 15:24:46.923 cbea8001-8a7e-448d-88a0-99e9cfef13b3 surveysparrow: false
INFO 15:24:46.923 cbea8001-8a7e-448d-88a0-99e9cfef13b3 before requestCredentials
ERROR 15:24:46.924 cbea8001-8a7e-448d-88a0-99e9cfef13b3 [NEEDS_AUTHENTICATION_ERR: Authentication Required] {
status: 401,
serviceKey: 'surveysparrow',
options: { scopes: undefined, isExpectedError: true }
}
ERROR 15:24:46.924 cbea8001-8a7e-448d-88a0-99e9cfef13b3 Failed to request credentials
I have gone through the same issue in this forum for slack oauth . but in surveysparrow case its not working . FYI adding Surveysparrow OAuth docs here . Waiting for your help . Thanks in advance