Using CI_JOB_TOKEN to clone another GitLab repo causes too many redirects or authentication replays

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Background

We have an issue with GitLab on our self-hosted instance, but I think the same issue exists with gitlab.com.

Using the CI_JOB_TOKEN to make a git clone call (using pygit2) we get the following error message:

_pygit2.GitError: too many redirects or authentication replays

The clone command is executed in a pipeline and it tries to clone another git repository in our GitLab instance.

  1. We have added the project running the pipeline to Settings > CI/CD Settings > Token Access > Allow access to this project with a CI_JOB_TOKEN in the repo to be cloned.
  2. It works if we use a Personal Access Token instead.
  3. We have confirmed the error message with a simple curl command as well.

It seems that there is some logic to CI_JOB_TOKEN that we have missed.

Edited Sep 12, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading