Forge Authorize API in JSD for customers

Hello I’m trying to collect all projects where the customer has access. I’m using Forge Authorize API , but it’s not working at all.

Documentation for Auth Forge API

import { authorize } from "@forge/api";

await authorize().onJira([
    {
     permissions: ['BROWSE_PROJECTS'],
     projects: [project.id]
    }])

And the response I get is empty array with status 200 OK.

Then I tried Find users with browse permission

/rest/api/3/user/viewissue/search?&accountId=${userId}&projectKey={projectKey}

The result is the same… Response 200 and array is empty
image

Then I tried Get bulk permissions

Still nothing… I get this response:

image

I need some help, how I’m able to collect all projects where my customer has access?

Hi @DonchoDonchev
I recommend using the following API: Jira Cloud REST API - Project Search. This endpoint can be accessed anonymously and will return a list of all projects available to the current user.

Already tried it and when call is api.asUser() and when the user type is Customer it’s not working.
There response returns empty array of values

image

When I call it api.asApp() it’s working, but returns all the projects.

I want only the projects where the customer user have access to it.

Ah, it sounds like you’re looking to retrieve all the projects available to your customers (Service Management projects with Service Desk portal). You can try making a standard fetch request to {CLOUD_URL}/rest/servicedeskapi/servicedesk (here’s the API reference: https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-servicedesk/#api-rest-servicedeskapi-servicedesk-get). Just be sure to grant the necessary fetch permissions in your manifest.yaml.

I already tried this also not working for customers, when I try to call it asUser() we get this error:

If I knew that Forge has problems with customers and getting information about them I would choose Connect. It’s very bad…
I’m not sure what else to test, because I think I’ve tried everything possible :slight_smile:

Also this rest /rest/servicedeskapi/servicedesk called with asApp() it’s returning all desks, which is useless again. When we run it from the browser or connect app it’s working as expected, returns the service desks where the customer has access.

Try to use the standard fetch function, not the requestJira wrapper. For more details on how to use fetch from the back-end, check out this link: https://developer.atlassian.com/platform/forge/runtime-reference/fetch-api.basic/

1 Like