Document toolboxDocument toolbox

Check access to a project using REST APIs

Hosting

CLOUD

Problem

A project is not accesible using the Projectrak REST API, even the owner of the  Projectrak token seems to have the permissions needded:

  • Jira: Browse projects
  • Projectrak: View project values

  • Projectrak: Edit project values

Reference: Projectrak permissions approach


The returned error is like:


Requirements

  1. Projectrak API token


    If you don’t have a Projectrak API token yet, follow the first steps (1 to 5) of this link .
    If you have already got it, you can reuse it.



  2. Jira API token

    If you don’t have a Jira API token yet, please go to this link and generate it:
    If you have already one, you can reuse it.

    Once created the Jira API token, open a Linux terminal and execute this command to generate a base64 authentication string:

    echo -n JIRA_USER_EMAIL:JIRA_API_TOKEN | base64

    For Windows powershell, please refer this link.
  3. Finally copy the result string, please.

Checks

  1. Get the a JWT from Projectrak using the Projectrak API token
    Using a REST client like Postman or Insomnia, call to the following Projectrak endpoint: /api-keys/jwt and copy the JWT




  2. Decode the JWT and get the user "accountId"
    Use the following util page: https://jwt.io/




  3. Get the Atlassian "accountId" for your user
    Call to the fowlloing Jira endpoint: /rest/api/3/myself.
    Use the Jira API token genereated.




  4. Check both 2 & 3 steps "accountId" are the same
    If not, the Projectrak API token you're using belongs to other user.
    If they're the same cotinue checking next step


  5. Check projects with the "BROWSE_PROJECT" permission using the Jira API
    The "BROWSE_PROJECTS" is a Jira permission needed to access a Project.

    Call to the following Jira endpoint:
    /rest/api/3/permissions/project, specifying the permissions to check.
    Use the Jira API token generated.

    Check if the target project is in the results.
    If not there, please check the project permission for the user using the Jira instance Web interface.


  6. Get the project using the Jira API
    As you've checked projects with "BROWSE_PROJECT" permission you should get the project.

    Call to the following Jira endpoint:
    /rest/api/3/permissions/project
    Use the Jira API token generated.




  7. Get the project using the Projectrak API
    If you get the Project using the Jira API, you also should get it using the Projectrak API

    Call to the following Projectrak endpoint:
    /search/projects?pql="key" IN ("<projectKey>")
    Use the Projectrak token generated.





  8. Check Projectrak permissions on project

    Check the user permission to operate with Projectrak:
    • Projectrak: View project values

    • Projectrak: Edit project values
    • Projectrak: Switch layout

    Reference: Projectrak permissions approach


    Call to the following Projectrak endpoint: /permissions/projects/<projectId>
    Use the Projectrak token generated.