nb env auth
Authenticate a saved NocoBase env again, or update the authentication information saved for it. When the env name is omitted, the current env is used.
nb env auth supports three authentication methods: basic, token, and oauth. If --auth-type is omitted, the CLI first infers the method from the authentication options you pass. If it still cannot infer the method, it uses the authentication method already saved in the env.
Usage
Parameters
Compatibility options
Notes
The authentication methods work as follows:
basic: sign in to NocoBase with a username and password, then save the returned access token and usernametoken: save the API key or access token passed through--access-tokenoauth: start the browser authentication flow, then save the access token after authentication finishes
In an interactive terminal, the CLI prompts for --auth-type, --username, --password, or --access-token when needed. In non-interactive mode, basic authentication requires both --username and --password.
oauth authentication first tries Device Authorization Grant. When the OAuth server supports this flow, the command prints a verification URL and user code, then polls until the browser approval is complete. This works on remote or headless servers because it does not require a local callback listener.
If the OAuth server does not expose a device authorization endpoint, the command falls back to the PKCE loopback flow: start a local callback server, open the browser for authorization, exchange the token, and save it to the config file.
After authentication succeeds, the CLI automatically runs nb env update <name> to re-sync the env state.
Limits
[name]and--envcannot provide different environment names at the same time--access-tokencannot be used with--usernameor--password--auth-type oauthcannot be used with--access-token,--username, or--password--auth-type tokencannot be used with--usernameor--password--auth-type basiccannot be used with--access-token--access-token,--username, and--passwordcannot be empty after they are provided
Examples
For device authorization, follow the URL printed by the command and enter the displayed code in the browser.

