Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API key page #3845

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/dev/reference/apis/billing-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ You will also need an API key and API key ID to authenticate your session.
Your API key needs to have [Org owner permissions](/manage/manage/rbac/#organization-settings-and-roles) to use the billing client API.
To get an API key (and corresponding ID), you have two options:

- [Create an API key using the Viam app](/cloud/rbac/#add-an-api-key)
- [Create an API key using the Viam app](/operate/control/api-keys/#add-an-api-key)
- [Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key)

The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates a `BillingClient`:
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/reference/apis/data-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ To use the Viam data client API, you first need to instantiate a [`ViamClient`](
You will also need an API key and API key ID to authenticate your session.
To get an API key (and corresponding ID), you have two options:

- [Create an API key using the Viam app](/cloud/rbac/#add-an-api-key)
- [Create an API key using the Viam app](/operate/control/api-keys/#add-an-api-key)
- [Create an API key using the Viam CLI](/dev/tools/cli/#create-an-organization-api-key)

The following example instantiates a `ViamClient`, authenticating with an API key, and then instantiates a `DataClient`:
Expand Down
7 changes: 0 additions & 7 deletions docs/manage/manage/access.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ You can also remove the user by clicking on **Remove user**.

You can remove any organization except the primary owner from the shared list by clicking the **X** to the right of the location in the shared list.

## Rotate an API key

If you ever need to rotate an API key, click on the **Generate Key** button on the organization setting page to generate a new key.

Viam supports flexible key rotation with up to two keys in use at one time.
After generating a new secret key, update all references to the key in your code as soon as possible and then remove the old key.

## Collaborate safely

When you or your collaborators change the configuration of a machine or a group of machines in the Viam app, `viam-server` automatically synchronizes the configuration and updates the running resources within 15 seconds.
Expand Down
46 changes: 46 additions & 0 deletions docs/operate/control/api-keys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: "API keys"
linkTitle: "API keys"
weight: 50
layout: "docs"
type: "docs"
description: "Run control logic on a machine."
images: ["/general/code.png"]
date: "2024-01-13"
---

API keys grant access to organizations, locations, and machines.

To view all API keys in use for your organization and the locations and machines inside it, click on the organization dropdown in the top navigation bar and click on **Settings**.

{{<imgproc src="/fleet/api-keys.png" resize="700x" declaredimensions=true alt="API Keys table">}}

## Add an API key

On your organization's page, click **Generate key** to generate a new key.
Optionally, give the key a name.
Click on the **Resource** menu and choose what organization, location, or machine you want the key to grant access to.
If you select organization, your key grants access to all locations and machines contained within that organization.
If you select location, your key grants access to all of the machines contained within that location.

For **Role**, assign either an **Owner** or **Operator** role.
See [Permissions](/manage/manage/rbac/) for information about the privilege each role entails at each resource level.

## Change an API key's access

To edit an API key, click on **Show details** in the key's row of the key table's **Resources** column.

{{<imgproc src="/fleet/additional-details.png" resize="700x" declaredimensions=true alt="Additional details for a key">}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care that this shows the ID without a box over it? Not sure why that would matter without the key but just wondering how much we care about setting precedents and whether readers will wonder whether we meant to include it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this more as showing an example of what the the UI looks like rather than to show exactly where to find the button. So I think it's ok but if you want to add a box, that's fine too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant a redaction box--a solid grey box over the ID. Fine to leave if you're okay with it; just wanted to point it out in case we don't want to do this.


To edit the role, click on the dropdown menu next to the role and select **Owner** or **Operator**.
See [Permissions](/manage/manage/rbac/) for information about the privilege each role entails at each resource level.

To change the entities it is able to access, click **+ Grant additional access**.
Select which organization, location, or machine you want the key to grant access to.
Click **Choose** to confirm your selection.

## Rotate an API key

If you ever need to rotate an API key, click on the **Generate Key** button on the organization setting page to generate a new key.

Viam supports flexible key rotation with up to two keys in use at one time. After generating a new secret key, update all references to the key in your code as soon as possible and then remove the old key.
8 changes: 4 additions & 4 deletions static/include/app/apis/generated/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/

### GetRobotAPIKeys

Gets the [API keys](/cloud/rbac/#api-keys) for the machine.
Gets the [API keys](/operate/control/api-keys/) for the machine.

{{< tabs >}}
{{% tab name="Python" %}}
Expand Down Expand Up @@ -2140,7 +2140,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/

### CreateKey

Create a new [API key](/cloud/rbac/#api-keys).
Create a new [API key](/operate/control/api-keys/).

{{< tabs >}}
{{% tab name="Python" %}}
Expand Down Expand Up @@ -2184,7 +2184,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/

### DeleteKey

Delete an [API key](/cloud/rbac/#api-keys).
Delete an [API key](/operate/control/api-keys/).

{{< tabs >}}
{{% tab name="Python" %}}
Expand All @@ -2210,7 +2210,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/

### RotateKey

Rotate an [API key](/manage/manage/access/#rotate-an-api-key).
Rotate an [API key](/operate/control/api-keys/#rotate-an-api-key).

{{< tabs >}}
{{% tab name="Python" %}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Gets the [API keys](/cloud/rbac/#api-keys) for the machine.
Gets the [API keys](/operate/control/api-keys/) for the machine.
2 changes: 1 addition & 1 deletion static/include/app/apis/overrides/protos/app.RotateKey.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Rotate an [API key](/manage/manage/access/#rotate-an-api-key).
Rotate an [API key](/operate/control/api-keys/#rotate-an-api-key).
2 changes: 1 addition & 1 deletion static/include/program/authenticate.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ To authenticate yourself to your machine, you need

<!-- we will be releasing the ability to create API keys across all types of resources and combinations soon (i.e an API key can have an authorization on a org, location, machine or any combination of all three). this is correct for now though but it will be changing shortly. -->

To authenticate, [use a machine part API key](/cloud/machines/#api-keys) or [an API key](/dev/tools/cli/#authenticate) with access to the machine.
To authenticate, [use a machine part API key](/operate/control/api-keys/) or [an API key](/dev/tools/cli/#authenticate) with access to the machine.
Copy and paste the API key ID and the API key into your environment variables or directly into the code:

{{< tabs >}}
Expand Down
Loading