# Gitea 1.8.0 and Drone 1.1.0 unable to clone repository (2FA)

**URL:** <https://drone.discourse.group/t/gitea-1-8-0-and-drone-1-1-0-unable-to-clone-repository-2fa/10529>\
**Category:** Drone Support\
**Created:** [April 27, 2019, 3:38pm UTC](https://drone.discourse.group/t/gitea-1-8-0-and-drone-1-1-0-unable-to-clone-repository-2fa/10529 "2019-04-27T15:38:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![davebv](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/davebv/32/4481_2.png) [@davebv](https://drone.discourse.group/u/davebv)\
**Post date:** [April 27, 2019, 3:38pm UTC](https://drone.discourse.group/t/gitea-1-8-0-and-drone-1-1-0-unable-to-clone-repository-2fa/10529/1 "2019-04-27T15:38:17Z")

</div>

When setting up drone and gitea, my user cannot log in, the the following message:

> Login Failed. Forbidden

Before pulling the latest gitea and drone docker images I was able to login.

Current versions:

- Drone from docker drone/drone:1
- Gitea from docker gitea/gitea:1 (799f5e0)
- Reverse proxy: traefik

Gitea logs:  
[Macaron] 2019-04-27 10:07:20: Started GET /api/v1/users/[:user]/tokens for 88.217.37.92  
gitea\_1 | [Macaron] 2019-04-27 10:07:20: Completed GET /api/v1/users/[:user]/tokens 403 Forbidden in 37.509493ms

(Where [:user] is my username)

Is this due to the way the api in Gitea works? api/v1/users/[:user]/tokens requires basic authentication in url?

Is there anything I would miss from configuration below?

Thanks a lot for your help!

My docker-compose.yml is as follows:

```
version: "3.7"

services:
  gitea:
    image: gitea/gitea:1
    restart: always
    volumes:
      - gitea:/data
    ports:
      - "222:22"
    networks:
      - traefik

  drone:
    image: drone/drone:1
    restart: always
    volumes:
      - drone:/data
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_GITEA_SERVER=https://${GITEA_SERVER_HOST}
      - DRONE_GIT_ALWAYS_AUTH=true
      - DRONE_RUNNER_CAPACITY=2
      - DRONE_SERVER_HOST=${DRONE_SERVER_HOST}
      - DRONE_SERVER_PROTO=https
      - DRONE_TLS_AUTOCERT=false
      - DRONE_AGENTS_ENABLED=false
    networks:
      - traefik

volumes:
  gitea:
  drone:

networks:
  traefik:
    external: true
    name: traefik

```

I omitted the labels for traefik configuration to make it more readable.

---

<div class="post-metadata">

**Author:** ![davebv](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/davebv/32/4481_2.png) [@davebv](https://drone.discourse.group/u/davebv)\
**Post date:** [April 27, 2019, 5:14pm UTC](https://drone.discourse.group/t/gitea-1-8-0-and-drone-1-1-0-unable-to-clone-repository-2fa/10529/2 "2019-04-27T17:14:36Z")

</div>

Update:

I made the login work creating an oauth2 application in Gitea and adding the following to the environment in the drone service:

```
- DRONE_GITEA_CLIENT_ID= __client_id__
- DRONE_GITEA_CLIENT_SECRET= __secret__

```

It seems for drone 1.1.0 (as stated in the changelog) the gitea now supports oauth2.

Now the next problem is cloning does not work:

```
1 Initialized empty Git repository in /drone/src/.git/
2	+ git fetch origin +refs/heads/master:
3	fatal: could not read Username for 'https://URL': No such device or address

```

Gitea logs the following:  
Completed GET /_user_/repo.git/info/refs?service=git-upload-pack 401 Unauthorized

Where _user_ is my username, and repo.git is the name of the repository.

Any advice how to continue? Thanks!

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [April 27, 2019, 6:08pm UTC](https://drone.discourse.group/t/gitea-1-8-0-and-drone-1-1-0-unable-to-clone-repository-2fa/10529/3 "2019-04-27T18:08:26Z")

</div>

I recommend searching discourse for `could not read Username` or `No such device or address`. There are well documented solutions for this issue, starting with [Gitea/Gogs - Git - No such device or address - Debugging](http://discuss.harness.io/t/gitea-gogs-git-no-such-device-or-address-debugging/4378)

---

<div class="post-metadata">

**Author:** ![davebv](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/davebv/32/4481_2.png) [@davebv](https://drone.discourse.group/u/davebv)\
**Post date:** [April 27, 2019, 6:14pm UTC](https://drone.discourse.group/t/gitea-1-8-0-and-drone-1-1-0-unable-to-clone-repository-2fa/10529/4 "2019-04-27T18:14:09Z")

</div>

Thanks for your reply @bradrydzewski  
I already checked all those links 🙂  
Also implemented the .drone.yml for debug, and finished without any issues. Curl works as expected.

Unfortunately I could not find the actual root cause (maybe I missed something on those posts?)

Another detail I found is given I have 2FA active in Gitea, I cannot pull the repo by username and password but I need the token.

What would be the right configuration?  
Should I then configure  
- DRONE\_GIT\_ALWAYS=true  
- DRONE\_GIT\_USERNAME=x-oauth-token  
- DRONE\_GIT\_PASSWORD=?

What would be the right password?

Thanks a lot for your help.

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [April 27, 2019, 6:50pm UTC](https://drone.discourse.group/t/gitea-1-8-0-and-drone-1-1-0-unable-to-clone-repository-2fa/10529/5 "2019-04-27T18:50:14Z")

</div>

There are known issues (in Gitea) with 2FA and their new oauth2 implementation as it related to cloning a repository. I believe the Gitea folks are working to patch this in the 1.8.1 release, according to techknowlogick (Gitea maintainer). You might want to check in the Gitea discord channel to get more information.

---

<div class="post-metadata">

**Author:** ![davebv](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/davebv/32/4481_2.png) [@davebv](https://drone.discourse.group/u/davebv)\
**Post date:** [April 27, 2019, 7:10pm UTC](https://drone.discourse.group/t/gitea-1-8-0-and-drone-1-1-0-unable-to-clone-repository-2fa/10529/6 "2019-04-27T19:10:13Z")

</div>

Thanks! I just saw the conversation and the patch is already merge into master branch. (I believe this is the PR)

> <https://github.com/go-gitea/gitea/pull/6747>
>
> This includes API calls and git clones
> (username is token and password is eithe…r empty or \`x-oauth-basic\`)
> 
> @jonasfranz If possible could you review as you have most knowledge of OAuth2 implementation.

I hope this is released soon.

---

<div class="post-metadata">

**Author:** ![techknowlogick](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/techknowlogick/32/4245_2.png) [@techknowlogick](https://drone.discourse.group/u/techknowlogick)\
**Post date:** [April 27, 2019, 11:29pm UTC](https://drone.discourse.group/t/gitea-1-8-0-and-drone-1-1-0-unable-to-clone-repository-2fa/10529/7 "2019-04-27T23:29:27Z")

</div>

For anyone coming here from search, what @bradrydzewski said above is correct. There was a bug in Gitea that’ll be released in 1.8.1. ~~The patch has been merged, and we are just waiting for a release which should be within the next week. Feel free to join us on [Gitea discord](https://discord.gg/gitea) if you need help in the interim.~~

Edit: Gitea v1.8.1 has been released
