Skip to content

Programmatic access to private pages

Is it possible to access files hosted via GitLab Pages programmatically (e.g. using cURL from a CI job) when only project members are allowed to access Pages? When a project is "private", cURL downloads the GitLab login page (obviously). I tried sending basic auth credentials with the username gitlab-ci-token and password $CI_JOB_TOKEN, but this didn't help. I couldn't find any documentation about programmatic access to private Pages.

Proposed Approach:

We will use the Authorization header for GitLab Pages calls. The minimum required scope for the token is read_api.

curl --header "Authorization: Bearer [TOKEN]" [Pages Project URL]

Supported access token types:

  1. personal access tokens
  2. project access token
  3. group access token
  4. OAuth 2.0 tokens

Documentation is available here.

Edited by Naman Jagdish Gala