Log in from the command line
You need the spotlight binary on your machine. To get it, see
Install script. You also need a
Spotlight account.
A login acts as you, with your role in each workspace that you are a member of. If you are an owner or admin, it can also manage secrets, runners and token trusts. See Roles. A login is for a person at a terminal. In CI, use an OIDC trust; see Run Terraform from GitHub Actions without a stored token.
Log in
Run:
spotlight loginIf you have no login yet, the command asks for the Spotlight address:
Spotlight address [https://app.usespotlight.ai]:Press Enter for https://app.usespotlight.ai, or type your deployment's
address, such as spotlight.example.com. The command then prints a page
address and a code, and waits:
Open this page to log in to https://app.usespotlight.ai:
https://app.usespotlight.ai/device?user_code=WDJBMJHT
Check that the page shows the code WDJB-MJHT.
Opened the page in your browser.
Waiting for you to approve the login. Press Ctrl-C to stop.On macOS and Linux, the command opens the page in your browser. If it does not,
or if you add --no-browser, open the address yourself. You can open it on a
different computer.
If the page asks you to log in, click Continue with GitHub.
The page shows "Approve the Spotlight CLI?" and a code. Make sure that the code is the same as the code in your terminal. Then click Approve.
If you did not run spotlight login, or the codes are different, click
Deny.
The page shows "Spotlight CLI is logged in". In your terminal, the command prints:
Logged in to https://app.usespotlight.ai as you@example.com.
Next: to open tasks in VS Code or Cursor, run: spotlight ssh setupThe Next line shows only when SSH is not set up for Spotlight on this
computer. See
Open a working copy in VS Code.
If the page asks for a code, type the code from your terminal and click Continue.
The command keeps the login in credentials.json, in ~/.config/spotlight.
See spotlight login for
the other places it can use.
Log in to a self-hosted Spotlight
Give your deployment's address
with --url, or set SPOTLIGHT_URL:
spotlight login --url https://spotlight.example.comThe command keeps one login for each address. To use more than one Spotlight, log in to each.
Use the login with Terraform
On your machine, spotlight login is enough. The provider needs no token and
no environment variables:
provider "spotlight" {}Then run terraform plan or terraform apply as usual. The provider uses your
login and its address, and Spotlight checks your role for each change. Runner
pools, secrets and trusts need a workspace admin.
If you logged in to more than one address, set url or SPOTLIGHT_URL to the
one to use. Do not set token, SPOTLIGHT_API_TOKEN, oidc.trust or
SPOTLIGHT_OIDC_TRUST. If one of them is set, the provider uses it, not your
login.
spotlight replay also uses the login when SPOTLIGHT_API_TOKEN is not set.
Set SPOTLIGHT_URL to the address that you logged in to. If you are a member of
more than one workspace, choose one with --workspace <slug> or
SPOTLIGHT_WORKSPACE. Terraform needs no choice, because each resource names
its workspace.
Log out
spotlight logoutThe command ends the session in Spotlight and removes the login from
credentials.json. It prints Logged out of <address>. For a self-hosted
Spotlight, add --url <address>.
If Spotlight does not answer, the command still removes the login, and prints that the token stays valid until it expires.
In a terminal, spotlight without a command opens a dashboard that shows the
login, by user and address. Press a to log in, or to log out. The dashboard
logs in on its own screen: it shows the page and the code, and waits for your
approval.
If something goes wrong
| What you see | What to do |
|---|---|
spotlight login: the code expired before the login was approved. Run spotlight login again | You did not approve within 15 minutes. Run spotlight login again. |
spotlight login: the login was denied in the browser | Someone clicked Deny. Run spotlight login again and click Approve. |
| The page shows "Code doesn't work" | The code expired, or it is not complete. Run spotlight login again and open the new address. |
Terraform shows No API token | The provider has no login. Run spotlight login. If you set url or SPOTLIGHT_URL, make sure that it is the address you logged in to. |
Terraform says there are logins for <addresses> | You logged in to more than one address. Set url or SPOTLIGHT_URL to the one to use. |
| Terraform says that the login expired or was revoked | The session ended. A session ends after 7 days without use. Run spotlight login --url <address> again. |
An API call gets 401 with The token is unknown, expired or revoked. or The token is not a current login. | The session ended, or you logged out. Run spotlight login again. |
Errors and messages lists every message.
Related
- spotlight login and spotlight logout: the flags, the credentials file and the exit codes.
- Provider configuration: the order in which the provider uses its credentials.
- Pools, trusts and tokens