# Io (gradients.sh Pro preset)

Source link: https://gradients.sh/studio/io

Io is a Pro preset. Its settings are only served to a gradients.sh account with Pro, so this page can't show the install command yet.

1. Log this computer in, unless `npx gradients.sh whoami` already shows a Pro account: run `npx gradients.sh login` and follow "Pro setup" below (the user approves a link, then you run it again).
2. Fetch this page again with the token:

   ```bash
   TOKEN="${GRADIENTS_TOKEN:-$(npx -y gradients.sh token)}"
   curl -s -H 'Accept: text/markdown' -H "Authorization: Bearer $TOKEN" 'https://gradients.sh/studio/io'
   ```

   It then answers with the install command for this preset.

## Pro setup

Pro items install only for a gradients.sh account with Pro. The gradients.sh CLI does the login, the registries and the install in one command. Run it from the project folder:

```bash
npx gradients.sh add <name>
```

`<name>` is a component (`god-rays`), a namespaced name (`@gradients-pro/god-rays`, `@gradients-config/<code>`, `@gradients-saved/<id>`) or a gradients.sh link. The command finds the project's `components.json` (running `shadcn init` if there is none), adds the gradients.sh registries to it, and runs `shadcn add` with the token. Flags such as `--overwrite` go through to shadcn. If shadcn stops to ask about overwriting a file that already exists, rerun with `--overwrite` only if the user agrees.

The first time on a computer, the user approves a login:

1. The command prints a link and a code, then exits with code 2. Nothing in the project has changed yet.
2. Show the user the link and the code. Ask them to open the link, check the code matches, and approve. They sign in there if needed. Never open or approve the link yourself.
3. When they say they approved, run the same command again. It picks up the approval and installs. If they haven't approved yet, it waits up to 30 seconds and prints the link again.

The login is saved for the whole computer in the user's config folder (`~/.config/gradients.sh/`), not in the project, so there is nothing to commit or gitignore and later installs in any project skip the approval. `npx gradients.sh whoami` shows the account, `npx gradients.sh logout` revokes it, and `npx gradients.sh token` prints the token for scripts. A `GRADIENTS_TOKEN` set in the environment (CI) takes precedence over the login.

If the command says the account has no Pro plan, tell the user: plans are at https://gradients.sh/pricing.

### Without the CLI

For tools that can't run Node, or to wire the token in by hand:

1. Start a device login:

   ```bash
   curl -s -X POST https://gradients.sh/api/agent/login -H 'content-type: application/json' -d '{"client":"<your agent name>"}'
   ```

   The response has `verificationUrl`, `userCode`, `deviceCode`, `interval` and `expiresIn`. Show the user the link and the code, and ask them to approve as above. Then poll every `interval` seconds until it answers 200 (it expires after `expiresIn` seconds):

   ```bash
   curl -s -X POST https://gradients.sh/api/agent/login/token -H 'content-type: application/json' -d '{"deviceCode":"<deviceCode>"}'
   ```

   - 202 `{"status":"pending"}`: not approved yet, keep polling.
   - 200 `{"status":"approved","token":"gcn_pat_..."}`: done.
   - 403 `denied`, 410 `expired`: stop and tell the user.

   Write the token to `.env.local` as `GRADIENTS_TOKEN=gcn_pat_...` and make sure `.env.local` is in `.gitignore`. Don't print the token in your reply or commit it. The shadcn CLI reads `.env.local` itself. (`npx gradients.sh login --project` does this step too.)

2. Add the gradients.sh registries to `components.json` (merge with any `registries` already there):

   ```json
   {
     "registries": {
       "@gradients": "https://gradients.sh/r/{name}.json",
       "@gradients-pro": {
         "url": "https://gradients.sh/r/pro/{name}.json",
         "headers": { "Authorization": "Bearer ${GRADIENTS_TOKEN}" }
       },
       "@gradients-config": {
         "url": "https://gradients.sh/r/c/{name}.json",
         "headers": { "Authorization": "Bearer ${GRADIENTS_TOKEN}" }
       },
       "@gradients-saved": {
         "url": "https://gradients.sh/r/s/{name}.json",
         "headers": { "Authorization": "Bearer ${GRADIENTS_TOKEN}" }
       }
     }
   }
   ```

3. Install Pro items by name with `npx shadcn@latest add @gradients-pro/<name>` (or `@gradients-config/<code>`, `@gradients-saved/<id>`). The shadcn CLI sends the token only for namespaced names, never for a bare URL.

A 401 means no token was sent; a 403 means the token is wrong, revoked, unused for 90 days, or the account has no Pro (https://gradients.sh/pricing). For a 403 with Pro, log in again for a new token.

Tools that speak the OAuth 2.0 device grant (RFC 8628) can use it instead of step 1: the server metadata is at https://gradients.sh/.well-known/oauth-authorization-server.
