I want to send the contents of a Confluence page to one of my APIs with the authorization done with Slack. I have the following resolver code:
resolver.define('summarise', async (req) => {
const pageId = req.payload.pageId;
const confluenceAPIResult = await api.asUser().requestConfluence(route`/wiki/api/v2/pages/${pageId}?body-format=atlas_doc_format`);
const json = await confluenceAPIResult.json();
const body = JSON.parse(json.body.atlas_doc_format.value);
const atlasBotAPI = api.asUser().withProvider('slack', 'atlasbot-api');
if(!await atlasBotAPI.hasCredentials()) {
await atlasBotAPI.requestCredentials();
}
const accounts = await atlasBotAPI.listAccounts();
console.log(`accounts: ${inspect(accounts, false, null, true)}`);
const account = await atlasBotAPI.getAccount();
console.log(`account: ${inspect(account, false, null, true)}`);
const options = {
method: 'POST',
body: JSON.stringify(body)
};
try {
const atlasBotAPIesult = await atlasBotAPI.fetch(route`/0_0_1/atlas-webhook`, options);
console.log(`slackResult: ${inspect(atlasBotAPIesult, false, null)}`);
}
catch(error) {
console.error(error);
console.log(`error: ${util.inspect(error, false, null, true)}`);
}
});
My manifest.yml looks like this:
modules:
confluence:contentBylineItem:
- key: atlasbot-content-byline-item
resource: main
resolver:
function: resolver
render: native
title: atlasbot
function:
- key: resolver
handler: index.handler
providers:
auth:
- slack
resources:
- key: main
path: src/frontend/index.tsx
app:
runtime:
name: nodejs18.x
id: ari:cloud:ecosystem::app/my-id
permissions:
scopes:
- read:page:confluence
external:
fetch:
backend:
- remote: atlasbot-api
- remote: slack-com
providers:
auth:
- key: slack
name: Slack
scopes:
- 'openid'
- 'email'
- 'profile'
type: oauth2
clientId: 'my-slack-app-client-id'
remotes:
- slack-com
bearerMethod: authorization-header
actions:
authorization:
remote: slack-com
path: /openid/connect/authorize
exchange:
remote: slack-com
path: /api/openid.connect.token
retrieveProfile:
remote: slack-com
path: /api/openid.connect.userInfo
resolvers:
id: sub
displayName: name
avatarUrl: picture
remotes:
- key: atlasbot-api
baseUrl: https://atlasbot.example.com
- key: slack-com
baseUrl: https://slack.com
I have posted this to https://community.developer.atlassian.com/t/withprovider-not-substituting-remote-name-when-using-external-auth-in-forge-app/80577 as I think that's a more appropriate forum.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.