Skip to content

Commit

Permalink
Merge pull request #340 from NobodysNightmare/using-api-keys
Browse files Browse the repository at this point in the history
Describe how to use an API key created via web UI
  • Loading branch information
hsbt authored Nov 21, 2023
2 parents b2201a9 + 0484349 commit f7ba30c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion api-key-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ The *Age* column shows how old is the key. The *Last access* column shows the la
Usage with gem CLI
------------------

An API key created as outlined above can be used in the `gem` CLI directly by setting it in an environment variable called `GEM_HOST_API_KEY`, e.g.

$ GEM_HOST_API_KEY=rubygems_123456 gem push example-1.2.3.gem

This approach is suitable for non-interactive situations, e.g. for CI/CD-based gem publishing processes. On a personal development machine that you can directly access, the interactive sign-in using `gem signin` (see below) is usually preferrable.

Creating from gem CLI
---------------------

**Note:** You need rubygems 3.2.0 or newer if you like to create API keys with scopes from the gem CLI.

Running `gem signin` will prompt you for your RubyGems.org credentials, key name, and scopes to enable for the key. The default choice for all scopes is not to enable them.
Expand Down Expand Up @@ -85,7 +94,7 @@ Enable MFA on specific API keys

If your account has MFA enabled on the **UI only** or **UI and gem signin** [authentication level](https://guides.rubygems.org/setting-up-multifactor-authentication/#authentication-levels), you have the option to enable MFA on a specific API key. This will require an OTP code for `gem push`, `yank`, `owner --add/--remove` commands.

You can toggle this option when creating or editing an API key on the UI.
You can toggle this option when creating or editing an API key on the UI.
![New API key with MFA enabled](/images/new-mfa-api-key.png){:class="t-img"}

Migration from legacy-api key
Expand Down

0 comments on commit f7ba30c

Please sign in to comment.