From 2bb8cbc6032f581c13236f6fdaa9b244e3e01ee9 Mon Sep 17 00:00:00 2001 From: dcz_pf Date: Thu, 21 Nov 2024 18:25:56 +0000 Subject: [PATCH] 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 Reviewed-on: https://codeberg.org/forgejo/docs/pulls/939 Reviewed-by: Earl Warren Co-authored-by: dcz_pf Co-committed-by: dcz_pf --- docs/user/packages/cargo.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/user/packages/cargo.md b/docs/user/packages/cargo.md index 245e0598..2f9bce9f 100644 --- a/docs/user/packages/cargo.md +++ b/docs/user/packages/cargo.md @@ -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