Personal Access Tokens

Create a Personal Access Token to access multiple Seam workspaces using a single credential.

In some instances, it may be necessary to access multiple workspaces with a single Seam credential. For example, you may want to set up separate workspaces for each of your users to control different sets of devices. For more information about scenarios in which multiple workspaces are useful, see Per-Customer Workspace Setup.

Because API keys are scoped to a single workspace, Seam provides Personal Access Tokens (PATs) to enable multi-workspace authorization. First, create a PAT. Then, use this PAT with a workspace ID to access the desired workspace.

Never use a PAT in a web browser or expose it to your users.

Create a Personal Access Token

  1. In the upper-right corner of the Seam Console, click your username and then Settings.

  2. In the left navigation pane, Personal Access Tokens.

  3. In the upper-right corner of the Personal Access Tokens page, click + Add Personal Access Token.

  4. In the Add Personal Access Token dialog, type a name for your new PAT and then click Create Personal Access Token.

  5. Copy the newly-created PAT and store it for future use.

Using the PAT to issue a Seam API request

To use a PAT for authorization in the Seam API, you must specify the PAT in the Authorization header for the Seam HTTP API or in the seam constructor for the Seam SDK that you are using. You must also specify the ID of the workspace that you want to access. If you are using the Seam HTTP API, include the seam-workspace header with the desired workspace ID. If you are using a Seam SDK, specify the desired workspace ID in the Seam constructor.

The following example shows how to use a PAT and workspace ID to list all devices in a workspace:

seam = Seam(
    # Specify PAT.
    api_key=pat,
    # Specify workspace ID.
    workspace_id=workspaceId
)

pprint(seam.devices.list())

Instead of including your PAT in the Seam constructor, you can export your PAT as a SEAM_API_KEY environment variable. Then, all installed Seam SDKs automatically use this exported PAT.

$ export SEAM_API_KEY=${PAT}

Last updated

Logo

© Seam Labs, Inc. All rights reserved.