Downloading file from repository using CI_JOB_TOKEN

I’ve looked up the documentation here: GitLab Token overview | GitLab

Under “Available scopes” it says that Job token is able to access the repository, but I am trying to use the folllowing command:

    - curl "https://my.private.repo.com/api/v4/projects/$CI_PROJECT_ID/repository/archive.tar.gz?sha=$CI_COMMIT_SHA?job_token=$CI_JOB_TOKEN" --output file.tar.gz 

But it doesn’t work. If I switch to my personal ACCESS_TOKEN it works. Why is this happening?

Hi @RafaelMoreiraSkrey
it should be curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.com/api/v4/projects/<project_id>/repository/archive?sha=<commit_sha>"

I know, but isn’t there a way to use the CI_JOB_TOKEN instead of an Access Token?

I’m not sure what you’re downloading there, but this is the list of API endpoints that the CI_JOB_TOKEN can authenticate.