Need Help with Cloning a Private Repository Using OAuth2 Tokens

Hi everyone,

I am currently trying to clone a private repository from an GitLab self-managed instance (CE v16.10.1) using tokens generated via OAuth2 API, but I’m facing some challenges. I’ve generated the OAuth2 tokens as per the documentation (https://docs.gitlab.com/ee/api/oauth2.html), but I’m unsure of the correct steps to use these tokens to clone the repository.

Here’s what I’ve tried so far:

  1. Generating the OAuth2 token from the GitLab OAuth2 flow successfully (with api scope).
  2. Using the token with the git clone command like this:
git clone https://oauth2:TOKEN@URL/REPO.git

However, I keep getting authentication errors (2FA is disabled):

Can anyone guide me on how to correctly use the OAuth2 tokens for cloning a private repository? Any example commands or a step-by-step process would be really helpful.

Thanks in advance for your assistance!