Authenticate using access token?


#1

I want to use an OAuth access token to perform actions which are not available with the official API.

I noticed that one can authenticate with a CI token like this:
git clone https://gitlab-ci-token:token@gitlab.com/project.git

I would like to do the same but with an access token. Something like:
git clone https://gitlab-oauth-token:token@gitlab.com/project.git

Is this possible?

More context: I am using JGit to make changes to a git repository hosted on Gitlab. But I don’t want to ask users for their user & password. I need to use an access token. I am getting the access token by making the users follow an OAuth flow.


#2

Answering my own question:

It’s possible to use an access token like this:
git clone https://oauth2:token@gitlab.com/project.git

source: https://stackoverflow.com/a/29570677/8450742