Skip to main content

LogInClientCredentials

Non-interactive login using OAuth2 client_credentials. Reads the client ID from -id or OCTO_CLI_CLIENT_ID and the secret from OCTO_CLI_CLIENT_SECRET, standard input (--secret-stdin) or a hidden prompt. Tenant comes from the effective context (--context, OCTO_CLI_CONTEXT or the active one).

Examples​

Headless run — export credentials, then login:

octo-cli -c LogInClientCredentials

Or pipe the secret in on standard input (e.g. from a secret store); -id takes precedence over the env var:

octo-cli -c LogInClientCredentials -id "my-script-client" -ss

Options​

ShortLongRequiredDescription
-id--clientIdnoClient ID. Falls back to env var OCTO_CLI_CLIENT_ID
-s--secretnoDeprecated: client secret. A value on the command line ends up in the shell history and the process list.
Omit it to be prompted (hidden input), or use --secret-stdin or the environment variable OCTO_CLI_CLIENT_SECRET.
-ss--secret-stdinnoRead the client secret from standard input (one value; a trailing line break is removed)
-rl--replace-loginnoReplace the context's login even if it holds an interactive login, or if the requested context name
matched the stored one only by case. Without it the command refuses and changes nothing.

Notes​

Secret sources, first match wins: --secret-stdin, OCTO_CLI_CLIENT_SECRET, a hidden prompt (only on a terminal). -s still works in this release but logs a deprecation warning and will be removed, because a value on the command line ends up in the shell history and the process list.

Tenant comes from the effective context. Target a different tenant with --context <name> (or OCTO_CLI_CONTEXT) for one invocation, or switch the active context with UseContext. The login fails fast if that context has no TenantId.

The client is per-tenant. If a script needs to address multiple tenants, create one client_credentials client per tenant and switch contexts before each login.

No refresh token is issued (per OAuth2 spec for client_credentials). While OCTO_CLI_CLIENT_ID and OCTO_CLI_CLIENT_SECRET remain set in the environment, octo-cli automatically re-acquires the token when it expires — long-running scripts do not need to call LogInClientCredentials again between commands. If the env vars are unset, the next API call after expiry returns 401 and you must re-run the login.

The token is stored in the effective context's Authentication block (--context, OCTO_CLI_CONTEXT or the active context), exactly like a device-code token.

Context names are matched case-insensitively. The command refuses, names the matched context and changes nothing when the context holds an interactive login (LogIn) or when the name given with --context / OCTO_CLI_CONTEXT matched the stored context only by case; pass --replace-login to replace the login anyway, or add a separate context for the client.