I have the following manifest file for my app::
providers:
auth:
- key: slack
name: Slack
scopes:
- incoming-webhook
- users.profile:read
type: oauth2
clientId: 'clientId'
remotes:
- slack-apis
bearerMethod: authorization-header
actions:
authorization:
remote: slack-apis
path: /oauth/v2/authorize
exchange:
remote: slack-apis
path: /api/oauth.v2.exchange
revokeToken:
remote: slack-apis
path: /api/auth.revoke
retrieveProfile:
remote: slack-apis
path: /api/users.profile.get
resolvers:
id: avatar_hash
displayName: display_name
avatarUrl: picture
remotes:
- key: remote-backend
baseUrl: 'https://${BACKEND_DOMAIN}'
auth:
appUserToken:
enabled: true
appSystemToken:
enabled: true
operations:
- compute
- fetch
- key: slack-apis
baseUrl: 'https://slack.com'
permissions:
content:
styles:
- unsafe-inline
external:
fetch:
backend:
- 'https://slack.com'
images:
- '*.atlassian.net'
- '*.wp.com'
modules:
jira:projectPage:
- key: webim-project-page
resource: main
resolver:
function: resolver
# render: native
layout: blank
title: Leiga Assistant
function:
- key: resolver
handler: index.handler
providers:
auth:
- slack
- key: handle-request-backend
handler: index.handleRequestBackend
resolvers code
resolver.define('getSlackToken', async () => {
const slack = asUser().withProvider('slack', 'slack-apis');
const isAuthenticated = await slack.hasCredentials();
logger.debug(`slack: ${isAuthenticated}`);
if (!isAuthenticated) {
logger.debug('before requestCredentials');
try {
await slack.requestCredentials();
} catch (e) {
console.error(e);
logger.error('Failed to request credentials');
throw e;
}
logger.debug('after requestCredentials');
}
const res = await slack.fetch('/api/openid.connect.token');
if (res.ok) {
return res.json();
}
return {
code: 401,
message: 'Failed to get slack token',
};
});
In the UI, there is a button that, when clicked, invokes the âgetSlackTokenâ function. The console logs are as follows:
DEBUG 17:06:24.307 3b71cb84-affc-4dab-a5dc-56947082bf77 resolvers - {"message":"slack: false"}
DEBUG 17:06:24.307 3b71cb84-affc-4dab-a5dc-56947082bf77 resolvers - {"message":"before requestCredentials"}
ERROR 17:06:24.307 3b71cb84-affc-4dab-a5dc-56947082bf77 [NEEDS_AUTHENTICATION_ERR: Authentication Required] {
status: 401,
serviceKey: 'slack',
options: { scopes: undefined, isExpectedError: true }
}
ERROR 17:06:24.307 3b71cb84-affc-4dab-a5dc-56947082bf77 resolvers - {"message":"Failed to request credentials"}
After clicking the access button, Slack authorization is processed, and it redirects to a new window, which then closes automatically. However, my Forge app page still shows the authorization information. Even after refreshing, the app remains unauthorized.
I need help resolving this issue. Thank you!