CI_JOB_TOKEN gives 401 on api/v4/groups/:id/projects call?

I thought the CI_JOB_TOKEN has the same access as the user triggering the job. With my personal access token it works, but it fails when using CI_JOB_TOKEN

curl -s --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "https://gitlab.acme.com/api/v4/groups/70/projects" {"message":"401 Unauthorized"}

  • *GitLab 13.2.4
  • *Runner 13.2.1
versions:
  stage: versions
  script:
    - 'curl -s --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "https://gitlab.badgersystems.de/api/v4/groups/70/projects"'

Hi @oschrenk,
as stated in the documentation:

GitLab API cannot be used via CI_JOB_TOKEN but there is a proposal to support it.

Ah. What a pity and what a jungle of tickets have been created in pursuit of this. I’ll just have to work around for the time.

Thank you for the answer and the link.

1 Like