0
0
Fork 0
mirror of https://codeberg.org/forgejo/docs.git synced 2024-11-21 17:36:59 -05:00

Clarify API token usage (#939)

The config section can be easily missed when someone intends to only use the token as an env var. But that section contains the crucial bit of information about formatting the token.
This splits the credentials info from configuration description and makes the format explicit. While at it, the necessary permission is highlighted.

This should fix Codeberg/Community#1701

Co-authored-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/forgejo/docs/pulls/939
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: dcz_pf <cobepfac.dcz@porcupinefactory.org>
Co-committed-by: dcz_pf <cobepfac.dcz@porcupinefactory.org>
This commit is contained in:
dcz_pf 2024-11-21 18:25:56 +00:00 committed by Earl Warren
parent 5fbb96de9f
commit 2bb8cbc603

View file

@ -50,8 +50,14 @@ index = "sparse+https://forgejo.example.com/api/packages/{owner}/cargo/" # Spars
| --------- | ------------------------- |
| `owner` | The owner of the package. |
If the registry is private or you want to publish new packages, you have to configure your credentials.
Add the credentials section to the credentials file located in the current users home directory (for example `~/.cargo/credentials.toml`):
## Credentials
If the registry is private or you want to publish new packages, you must use your credentials to access it.
The Cargo registry requires an [API token](https://codeberg.org/user/settings/applications) with the "write:packages" permission.
To obtain a token useable by Cargo, prepend the string "Bearer " to your API token.
To store the token in your configuration, add the credentials section to the credentials file located in the current users home directory (for example `~/.cargo/credentials.toml`):
```
[registries.forgejo]
@ -70,7 +76,7 @@ Since Rust 1.68, sparse is the default method for crates.io.
## Publish a package
Publish a package by running the following command in your project:
Publish a package by obtaining an [API token](#Credentials) and running the following command in your project:
```shell
cargo publish