Skip to content

Commit 36bde02

Browse files
Add documentation for OTP/2FA header in API for basic auth (#6872)
1 parent 91c2c23 commit 36bde02

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/content/doc/advanced/api-usage.en-us.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ $ curl --request GET --url https://yourusername:yourpassword@gitea.your.host/api
8282
[{"name":"test","sha1":"..."},{"name":"dev","sha1":"..."}]
8383
```
8484

85+
As of v1.8.0 of Gitea, if using basic authentication with the API and your user has two factor authentication enabled, you'll need to send an additional header that contains the one time password (6 digit rotating token). An example of the header is `X-Gitea-OTP: 123456` where `123456` is where you'd place the code from your authenticator. Here is how the request would look like in curl:
86+
87+
```
88+
$ curl -H "X-Gitea-OTP: 123456" --request GET --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens
89+
```
90+
8591
## Sudo
8692

8793
The API allows admin users to sudo API requests as another user. Simply add either a `sudo=` parameter or `Sudo:` request header with the username of the user to sudo.

0 commit comments

Comments
 (0)