# Gitlab token not working

**URL:** <https://forum.reana.io/t/gitlab-token-not-working/64>\
**Category:** Uncategorized\
**Created:** [25 October 2022 14:55 UTC](https://forum.reana.io/t/gitlab-token-not-working/64 "2022-10-25T14:55:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hcai](https://forum.reana.io/letter_avatar_proxy/v4/letter/h/cdc98d/32.png) [@hcai](https://forum.reana.io/u/hcai)\
**Post date:** [25 October 2022 14:55 UTC](https://forum.reana.io/t/gitlab-token-not-working/64/1 "2022-10-25T14:55:32Z")

</div>

Dear experts,

We are using a custom c++ framework for our analysis, and I would like to clone the repository from git and compile on the fly.

However, my gitlab token is somehow not recognized.

remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See [https://gitlab.cern.ch:8443/help/topics/git/troubleshooting\_git#error-on-git-fetch-http-basic-access-denied](https://gitlab.cern.ch:8443/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied)

with the following specifications:

```
      "gitlab": true,
      "kerberos": true

```

In my gitlab, i have added the API of reana and given access to it.

Does anyone have some insight?

Many thanks,  
Huacheng

---

<div class="post-metadata">

**Author:** ![tiborsimko](https://forum.reana.io/user_avatar/forum.reana.io/tiborsimko/32/2_2.png) [@tiborsimko](https://forum.reana.io/u/tiborsimko)\
**Post date:** [27 October 2022 16:07 UTC](https://forum.reana.io/t/gitlab-token-not-working/64/2 "2022-10-27T16:07:43Z")

</div>

Hi @hcai

Granting REANA access to your GitLab repository, as mentioned on the [REANA-GitLab documentation page](https://docs.reana.io/advanced-usage/code-repositories/gitlab/), is used for fetching restricted images stored in your restricted GitLab project registries.

However, I assume that you are using an explicit `git clone` command-line call as part of your workflow steps? If yes, then the above isn’t sufficient.

Let’s assume the following `reana.yaml` serial workflow example with the HTTPS git clone command:

```yaml
inputs:
  files:
    - reana.yaml
workflow:
  type: serial
  specification:
    steps:
      - environment: 'python:3.8'
        kerberos: true
        commands:
          - git clone https://gitlab.cern.ch/johndoe/myrepo

```

If you have the two-factor authentication enabled for your CERN account, then the Kerberos authentication wouldn’t work (even with KRB5 git clone command) regardless of `kerberos: true` settings. GitLab requires to use a custom Personal Access Token (PAT), as the error message that you quoted indicated.

Have you created your PAT token on GitLab as mentioned in the [GitLab PAT documenation page](https://gitlab.cern.ch:8443/help/user/profile/personal_access_tokens.md#create-a-personal-access-token) and have you granted it at least the `read_repository` scope? If yes, then the cloning should work in the following manner.

Let’s say that your GitLab PAT token value is “abcd1234”. You can store it as a custom secret with REANA:

```auto
$ reana-client secrets-add --env GITLABPAT=abcd1234

```

This will make it available to your workflow jobs as an environment variable called GITLABPAT.

Afterwards, the `git clone` command in the above example should be modified to include the new secret:

```auto
          - git clone https://johndoe:$$GITLABPAT@gitlab.cern.ch/johndoe/myrepo

```

This change should allow the cloning of your restricted personal repositories. (Tested on the above toy example.)

Does this help to address your problem?

---

<div class="post-metadata">

**Author:** ![hcai](https://forum.reana.io/letter_avatar_proxy/v4/letter/h/cdc98d/32.png) [@hcai](https://forum.reana.io/u/hcai)\
**Post date:** [2 November 2022 15:48 UTC](https://forum.reana.io/t/gitlab-token-not-working/64/3 "2022-11-02T15:48:12Z")

</div>

Dear @tiborsimko ,

Sorry was traveling last week…

Yes this working perfectly for me now! Many thanks!

Best,  
Huacheng
