diff options
author | Patrick Schratz <patrick.schratz@gmail.com> | 2020-12-09 07:47:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-09 07:47:06 +0100 |
commit | af79677a44aec3924823d90f42e5cc2e6e1b2961 (patch) | |
tree | ed84af9ce17ff0f1337984b99f60d20541adf3da /docs/content/doc/developers/api-usage.en-us.md | |
parent | 97ab820accba40de66d7df7cdc5e396277483710 (diff) | |
download | gitea-af79677a44aec3924823d90f42e5cc2e6e1b2961.tar.gz gitea-af79677a44aec3924823d90f42e5cc2e6e1b2961.zip |
Reformat docs (#13897)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'docs/content/doc/developers/api-usage.en-us.md')
-rw-r--r-- | docs/content/doc/developers/api-usage.en-us.md | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/docs/content/doc/developers/api-usage.en-us.md b/docs/content/doc/developers/api-usage.en-us.md index 7dc6406a23..5253cbaa18 100644 --- a/docs/content/doc/developers/api-usage.en-us.md +++ b/docs/content/doc/developers/api-usage.en-us.md @@ -3,7 +3,7 @@ date: "2018-06-24:00:00+02:00" title: "API Usage" slug: "api-usage" weight: 40 -toc: true +toc: false draft: false menu: sidebar: @@ -15,12 +15,14 @@ menu: # API Usage +**Table of Contents** + {{< toc >}} ## Enabling/configuring API access By default, `ENABLE_SWAGGER` is true, and -`MAX_RESPONSE_ITEMS` is set to 50. See [Config Cheat +`MAX_RESPONSE_ITEMS` is set to 50. See [Config Cheat Sheet](https://docs.gitea.io/en-us/config-cheat-sheet/) for more information. @@ -33,7 +35,7 @@ Gitea supports these methods of API authentication: - `access_token=...` parameter in URL query string - `Authorization: token ...` header in HTTP headers -All of these methods accept the same API key token type. You can +All of these methods accept the same API key token type. You can better understand this by looking at the code -- as of this writing, Gitea parses queries and headers to find the token in [modules/auth/auth.go](https://github.com/go-gitea/gitea/blob/6efdcaed86565c91a3dc77631372a9cc45a58e89/modules/auth/auth.go#L47). @@ -54,13 +56,13 @@ Access tokens obtained from Gitea's [OAuth2 provider](https://docs.gitea.io/en-u For historical reasons, Gitea needs the word `token` included before the API key token in an authorization header, like this: -``` +```sh Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675 ``` In a `curl` command, for instance, this would look like: -``` +```sh curl -X POST "http://localhost:4000/api/v1/repos/test1/test1/issues" \ -H "accept: application/json" \ -H "Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675" \ @@ -73,10 +75,9 @@ the `token=` string in a GET request. ## API Guide: API Reference guide is auto-generated by swagger and available on: - `https://gitea.your.host/api/swagger` - or on - [gitea demo instance](https://try.gitea.io/api/swagger) - +`https://gitea.your.host/api/swagger` +or on +[gitea demo instance](https://try.gitea.io/api/swagger) ## Listing your issued tokens via the API @@ -87,14 +88,14 @@ using BasicAuth, as follows: ### Using basic authentication: -``` +```sh $ curl --request GET --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens [{"name":"test","sha1":"..."},{"name":"dev","sha1":"..."}] ``` 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: -``` +```sh $ curl -H "X-Gitea-OTP: 123456" --request GET --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens ``` @@ -104,5 +105,5 @@ The API allows admin users to sudo API requests as another user. Simply add eith ## SDKs -* [Official go-sdk](https://gitea.com/gitea/go-sdk) -* [more](https://gitea.com/gitea/awesome-gitea#user-content-sdk) +- [Official go-sdk](https://gitea.com/gitea/go-sdk) +- [more](https://gitea.com/gitea/awesome-gitea#user-content-sdk) |