feat: Improve login prompt (#642) · box/boxcli@a58ff34

@@ -9,8 +9,8 @@ overview of how the Box API handles authentication.

99

- [Server Auth with JWT](#server-auth-with-jwt)

1010

- [Server Auth with CCG](#server-auth-with-ccg)

1111

- [OAuth 2.0 Login (`box login`)](#oauth-20-login-box-login)

12-

- [Option 1: Official Box CLI App (Recommended)](#option-1-official-box-cli-app-recommended)

13-

- [Option 2: Your Own Custom App](#option-2-your-own-custom-app)

12+

- [Option 1: Official Box CLI App](#option-1-official-box-cli-app)

13+

- [Option 2: Your Own Platform App](#option-2-your-own-platform-app)

1414

- [Supported Ports](#supported-ports)

1515

- [Additional Flags](#additional-flags)

1616

- [Reauthorize OAuth2](#reauthorize-oauth2)

@@ -118,17 +118,17 @@ box configure:environments:add /path/to/config.json --ccg-auth --ccg-user "USER_

118118119119

The `box login` command authenticates you with Box using OAuth 2.0. It starts a local callback server, opens your browser for authorization, and stores the resulting tokens in a named environment.

120120121-

When you run `box login`, the CLI presents two login options: the **Official Box CLI App** and a **custom app** you create yourself. You can either choose interactively or skip the selection entirely using the `--default-box-app` (`-d`) flag.

121+

When you run `box login`, the CLI presents three options: the **Official Box CLI App**, a **Platform App** you create yourself, or **quit** (`q`) to exit. You can either choose interactively or skip the selection entirely using the `--default-box-app` (`-d`) flag. You can also paste a Client ID directly at the prompt — any input between 16 and 99 characters is treated as a Client ID.

122122123123

#### Option 1: Official Box CLI App

124124125125

This is the fastest way to get started with Box CLI. No app creation in the Box Developer Console is required — just run the command and authorize.

126126127-

**Interactive selection** — run `box login` and press **Enter** at the Client ID prompt to use the built-in app:

127+

**Interactive selection** — run `box login` and choose option `1` to use the built-in app, `2` for a Platform App, or `q` to quit:

128128129129

```bash

130130

box login

131-

# When prompted for a Client ID, press Enter to use the Official Box CLI App.

131+

# Choose [1] for Official Box CLI App, [2] for Platform App, or [q] to quit.

132132

```

133133134134

**Skip the prompt** — use the `--default-box-app` (or `-d`) flag to go directly to authorization:

@@ -141,23 +141,24 @@ box login --default-box-app

141141

box login -d

142142

```

143143144-

> **Note:** The Official Box CLI App uses scopes limited to content actions, which allows you to effectively manage your files and folders. If you need broader scopes (e.g., managing users, groups, or enterprise settings), use your own custom app instead.

144+

> **Note:** The Official Box CLI App uses scopes limited to content actions, which allows you to effectively manage your files and folders. If you need broader scopes (e.g., managing users, groups, or enterprise settings), use your own Platform App instead.

145145146-

#### Option 2: Your Own Custom App

146+

#### Option 2: Your Own Platform App

147147148148

If you need customized scopes or a dedicated application, you can log in with your own OAuth app. When prompted, enter the **Client ID** and **Client Secret** from your application's configuration.

149149150150

Before running the command, set up the app in the [Box Developer Console](https://cloud.app.box.com/developers/console):

151151152-

1. Select an application with **OAuth 2.0 user authentication** (or create a new Custom App).

152+

1. Select an application with **OAuth 2.0 user authentication** (or create a new Platform App).

153153

2. In the **Configuration** tab, set the **Redirect URI** to `http://localhost:3000/callback` (adjust the port if you use a different `--port` value).

154154

3. Click **Save Changes**.

155155156156

Then log in:

157157158158

```bash

159159

box login

160-

# When prompted, enter your Client ID and Client Secret.

160+

# Choose [2] when prompted, then enter your Client ID and Client Secret.

161+

# Alternatively, paste your Client ID directly at the prompt (any input between 16 and 99 characters is recognized as a Client ID).

161162

```

162163163164

For a step-by-step walkthrough, see the [Quickstart Guide](https://developer.box.com/guides/tooling/cli/quick-start/).

@@ -176,18 +177,19 @@ When using the **Official Box CLI App**, only the following ports are supported:

176177

| 5000 | `box login -d --port 5000` |

177178

| 8080 | `box login -d --port 8080` |

178179179-

When using your own custom app, any port can be used — just make sure the **Redirect URI** in the Developer Console matches `http://localhost:<port>/callback`.

180+

When using your own Platform App, any port can be used — just make sure the **Redirect URI** in the Developer Console matches `http://localhost:<port>/callback`.

180181181182

#### Additional Flags

182183183-

| Flag | Short | Description |

184-

|------|-------|-------------|

185-

| `--default-box-app` | `-d` | Use the Official Box CLI App and proceed directly to authorization. |

186-

| `--port <number>` | `-p` | Set the port for the local callback server. Default: `3000`. |

187-

| `--name <string>` | `-n` | Set a name for the environment. Default: `oauth`. |

188-

| `--reauthorize` | `-r` | Reauthorize an existing environment (requires `--name`). |

189-

| `--code` | `-c` | Manually visit the authorize URL and input the auth code. |

190-

| `--incognito-browser` | `-i` | Open the authorize URL in a private/incognito browser window. |

184+

| Flag | Short | Description |

185+

|------|-------|--------------------------------------------------------------------------------------|

186+

| `--default-box-app` | `-d` | Use the Official Box CLI App and proceed directly to authorization. |

187+

| `--platform-app` | | Skip the prompt and go directly to Platform App setup (Client ID and Client Secret). |

188+

| `--port <number>` | `-p` | Set the port for the local callback server. Default: `3000`. |

189+

| `--name <string>` | `-n` | Set a name for the environment. Default: `oauth`. |

190+

| `--reauthorize` | `-r` | Reauthorize an existing environment (requires `--name`). |

191+

| `--code` | `-c` | Manually visit the authorize URL and input the auth code. |

192+

| `--incognito-browser` | `-i` | Open the authorize URL in a private/incognito browser window. |

191193192194

#### Reauthorize OAuth2

193195