> For the complete documentation index, see [llms.txt](https://developer.celigo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.celigo.com/cli/commands/login.md).

# login

Sign in to integrator.io with OAuth — the alternative to an API token. `celigo login` opens the integrator.io sign-in in your browser, or gives you a code to enter on another device, then asks `GET /v1/tokenInfo` which account and environment the new session reached and stores the session as the profile's one credential, bound to that environment. The session acts as you, with your own permissions in the account and environment you sign in to, and renews itself until it is revoked or expires. [`celigo logout`](https://developer.celigo.com/cli/commands/logout.md) revokes it.

`login` manages local credentials, so it is never mode-gated.

> Added in celigo-cli 2026.10.1.

**REST API**: [Authentication](https://developer.celigo.com/api/getting-started/authentication)

```
celigo login [flags]
```

Supports all [global flags](https://developer.celigo.com/cli/getting-started/global-flags.md). `--profile` names the profile to sign in to, and `--base-url` the API host to sign in at (see [Which profile it signs in](#which-profile-it-signs-in)).

***

## `celigo login`

Sign in and store the session on a profile — `--profile`, else `CELIGO_PROFILE`, else the profile named after the account and environment the sign-in reaches, which is created if it does not exist. The active profile is never the default.

**Signature**

```bash
celigo login [--device] [--no-browser] [--timeout <seconds>] [--allow-account-mismatch]
```

**Arguments**

None.

**Flags**

| Flag                       | Type    | Default | Description                                                                                                                                                                                                                                                                    |
| -------------------------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--device`                 | boolean | `false` | Use the device authorization grant: the CLI prints a verification URL and a code, and you complete the sign-in in a browser on any device. Needs no local browser and no local port. Chosen on its own when stdin is not a terminal, or when a CI environment variable is set. |
| `--no-browser`             | boolean | `false` | Print the authorization URL instead of opening a browser. The redirect still returns to `127.0.0.1` on this machine, so open the URL in a browser on the same machine.                                                                                                         |
| `--timeout <seconds>`      | integer | `300`   | How long to wait for the browser sign-in, in whole seconds. The device grant waits until its code expires instead.                                                                                                                                                             |
| `--allow-account-mismatch` | boolean | `false` | Sign in even when the sign-in reaches another account or environment than the one the profile is bound to — or cannot be confirmed against it — and rebind the profile. An unconfirmed sign-in is stored unverified and clears the binding.                                    |

**Example**

```bash
# Sign in through the browser; the profile is named after the account and environment
celigo login

# An account in the EU region
celigo login --base-url https://api.eu.integrator.io

# Name the profile yourself (a new name creates it)
celigo login --profile acme-sandbox

# No browser on this machine: an SSH session, a container
celigo login --device

# Then confirm which account, environment, and credential the profile uses
celigo profile whoami
```

A browser sign-in that creates its profile prints:

```
Opening your browser to sign in to Celigo (https://integrator.io)...
  If the browser doesn't open, visit:  https://integrator.io/…
  Waiting for sign-in (Ctrl+C to cancel, times out in 5 minutes)...
Created profile 'acme-corp-production'.
Logged in to profile 'acme-corp-production' as Jane Doe — Acme Corp / Production (user 5f83a9b2c7d3e8f1a2b3c4d5 at api.integrator.io).
```

The device grant prints the page to visit and the code instead:

```
Visit <verification URL> and enter code:
  <user code>
  Waiting for sign-in (Ctrl+C to cancel)...
```

**Corresponds to**: the integrator.io OAuth sign-in — the authorization code grant with PKCE, or the device authorization grant — followed by [`GET /v1/tokenInfo`](https://developer.celigo.com/api/getting-started/authentication) with the new token, which says which account and environment the session reached.

### How the sign-in runs

The browser sign-in uses the authorization code grant with PKCE, as the `celigo-cli` public client. The CLI listens for the redirect on the first free port among `127.0.0.1:8787`, `8788`, and `8789` — the redirect URIs registered for that client — opens the sign-in page, and waits. When all three ports are busy it stops before opening anything:

```
Ports 8787, 8788, 8789 are all in use on 127.0.0.1 — the browser sign-in needs one of them for its redirect. Free one up, or use --device instead.
```

A sign-in not completed within `--timeout` stops the command; with the default 300 seconds the message is `Timed out waiting for the browser sign-in after 5 minutes. Run the command again, or use --device for a headless flow.`

The device grant needs neither a browser nor a port on this machine: complete the sign-in on a laptop for an SSH session, or on a phone. The CLI chooses it on its own when stdin is not a terminal, or when one of the CI variables `CI`, `CONTINUOUS_INTEGRATION`, `GITHUB_ACTIONS`, `JENKINS_URL`, `GITLAB_CI`, `CIRCLECI`, or `BUILDKITE` is set. The code is valid for as long as the authorization server says; once it expires, the command stops with `The device code expired before the sign-in was completed. Run the command again.`

Every sign-in requests the same scopes, `openid profile offline_access cli:read cli:write`, with a consent prompt, so the refresh token outlives the browser session. The platform does not distinguish `cli:read` from `cli:write` on a CLI session, so there is no narrower set to request: like a personal access token, the session can do what you can do. To keep a signed-in profile read-only, give it the `read` [permission mode](https://developer.celigo.com/cli/getting-started/profiles.md#permission-modes).

### Which profile it signs in

`login` signs in to `--profile`, else `CELIGO_PROFILE`, else the profile named after the account and environment the sign-in reaches. It never falls back to the active profile.

A named profile signs in at `--base-url`, else `CELIGO_BASE_URL`, else the profile's own `base_url`, else `https://api.integrator.io`. Since celigo-cli 2026.11.2, a blank `--base-url` (an unset shell variable) is refused before the sign-in starts; earlier releases read it as the flag left out and signed in at the next host in that order. Without a name, `login` signs in at `--base-url`, else `CELIGO_BASE_URL`, else `https://api.integrator.io`, then asks `GET /v1/tokenInfo` which account and environment the session reached and names the profile `<company>-<environment>`:

* The company is the account's company name, else the account owner's name; the environment is the environment's name.
* Both are folded the same way: accents dropped, lowercase, `&` as `and`, apostrophes dropped, and every other run of characters outside `a-z` and `0-9` as one `-`, with none at either end.
* The company part is cut to 24 characters at a word boundary.

| Account and environment                       | Profile name                      |
| --------------------------------------------- | --------------------------------- |
| `Acme Corp`, Production                       | `acme-corp-production`            |
| `Acme Corp`, Sandbox                          | `acme-corp-sandbox`               |
| `Acme Café & Bakery Supplies`, Production     | `acme-cafe-and-bakery-production` |
| No company name, owner `Jane Doe`, Production | `jane-doe-production`             |

When no profile has that name, `login` creates it. When one does, `login` signs it in again only if it is bound to the same environment and holds no API token; one bound to the same environment that holds a token is refused outright, at a terminal too. Any other collision is refused — the CLI never suffixes the name or renames another profile:

```
This sign-in reached Acme Corp / Production (user 5f83a9b2c7d3e8f1a2b3c4d5 at api.integrator.io), and the name it suggests, 'acme-corp-production', is taken by a profile that records no account — profiles are never renamed or suffixed automatically. The new session was revoked and nothing was saved. Sign in under a name of your own: celigo login --profile <name>
```

At a terminal, the CLI prints the reason and asks for another name instead — `Profile name for this sign-in ('acme-corp-production' is taken):` — until you type one it can use; an empty answer gives up. When `GET /v1/tokenInfo` fails or names no account or environment, or the account has neither a company nor an owner name, no name can be derived: the CLI asks at a terminal, and off one refuses with `No profile name could be derived from this sign-in: <reason>. The new session was revoked and nothing was saved. Sign in under a name of your own: celigo login --profile <name>`.

A name you choose must be one path component. A `--profile` name that is not one is refused before the sign-in starts; at the prompt, the CLI asks again. See [Profile names](https://developer.celigo.com/cli/getting-started/profiles.md#profile-names).

The first profile on the machine becomes the active profile. Any other profile `login` creates, or names for you, is printed with how to use it:

```
To use it, pass --profile acme-corp-sandbox, or make it this machine's active profile with celigo profile use acme-corp-sandbox
```

Under `profile_pin_policy = strict`, which refuses that `--profile`, the line names only `celigo profile use` — a person's command to run.

### The environment binding

Right after the token exchange, `login` asks `GET /v1/tokenInfo` — with the new token, at the profile's host — which environment the session reached, and records it. The identity is the environment's user (`_userId`) at the API host. It is kept in the config file's top-level `identities` map, labelled with the account id, company, and environment name, and the profile references it in its `identity` key (see [Config file schema](https://developer.celigo.com/cli/getting-started/configuration.md#config-file-schema)). The success line names the person who signed in, by name and never by email, and the environment reached:

```
Logged in to profile 'acme-corp-production' as Jane Doe — Acme Corp / Production (user 5f83a9b2c7d3e8f1a2b3c4d5 at api.integrator.io).
```

A later sign-in into the same profile that reaches another environment — another host, or another environment user, such as the same account's sandbox — is refused before anything is stored, and its new session is revoked:

```
Profile 'acme-corp-production' is bound to Acme Corp / Production (user 5f83a9b2c7d3e8f1a2b3c4d5 at api.integrator.io), but this sign-in reached Acme Corp / Sandbox (user 6a1b2c3d4e5f6a7b8c9d0e1f at api.integrator.io) — refusing to point the profile at another account. The new session was revoked and profile 'acme-corp-production' is unchanged. Sign in under another profile name (celigo login --profile <name>), or pass --allow-account-mismatch to rebind 'acme-corp-production' to this account.
```

A sign-in `GET /v1/tokenInfo` cannot confirm — the request fails, or the answer names no account or environment — is refused the same way for a profile that is already bound: storing it would leave the old binding vouching for a session nothing has checked. `--allow-account-mismatch` rebinds the profile to the environment the sign-in reached, or stores an unconfirmed session unverified and clears the binding; a `note:` on stderr says which. A profile that records no environment stores an unconfirmed session with a warning, and records no identity from it. The binding survives `logout`, so the next sign-in into the profile is held to it.

### One credential per profile

A profile holds one credential: its OAuth session or its API token, never both. `login` refuses a profile that stores an API token, before the browser opens:

```
Profile 'acme-sandbox' holds an API token, and a profile holds one credential. Sign in under another profile name instead, e.g. celigo login --profile acme-sandbox-oauth (a new name creates the profile).
```

`--token` and `CELIGO_API_TOKEN` still win over a stored session. When the variable is set, `login` says so on stderr: `note: CELIGO_API_TOKEN is set in this environment and wins over profile 'acme-corp-production''s sign-in until it is unset.`

A profile `login` creates has the default permission mode, `full`. To create a read-only signed-in profile, run `celigo profile add <name> --login --mode read`.

### Session renewal

A session renews itself before its access token expires, and once more when the API refuses the token — a `401`, or a `400` that refuses the token itself (an `invalid_token` challenge or error code, or `Bearer Authentication Failed`). Since celigo-cli 2026.11.2, a `401` that is a permission answer is not a refused token: the credential was accepted and the request is closed to it, so the session is not renewed and the error reads `(401): Not permitted: …`. Renewal holds a lock, `~/.celigo/oauth.lock`, so `celigo` commands running in parallel never spend one refresh token twice. When renewal fails, the command says why:

* The authorization server refused the refresh token — it expired or was revoked:

  ```
  Session expired for profile 'acme-corp-production'. Run: celigo login --profile acme-corp-production
  ```
* A `celigo logout` cleared the session while the command ran. The command fails at once, without waiting for the lock or spending the revoked refresh token:

  ```
  Profile 'acme-corp-production' is signed out — its session was cleared while this command ran. Run: celigo login --profile acme-corp-production
  ```
* The renewal failed for another reason — the authorization server is down or unreachable, or another process's renewal held the lock too long. The sign-in is kept, so retry before you sign in again:

  ```
  Could not renew the session for profile 'acme-corp-production': <reason> The sign-in is kept; retry the command, and sign in again (celigo login --profile acme-corp-production) only if this persists.
  ```

When the API still refuses a session it has just renewed, the message quotes the API and says the session is current, since a new sign-in is unlikely to help. A profile renamed or deleted while the command ran is named as such, with `celigo profile list` to find its current name, rather than sent to a new sign-in. Any other `400` is reported as the API sent it.

### Where the session is sent

A session is sent only to the API host it was issued for: the host of the environment the profile is bound to, else the `base_url` `login` stored with it. A `--base-url`, `CELIGO_BASE_URL`, or — for a promote target — `CELIGO_TARGET_BASE_URL` naming another host is refused before any request, with the way out:

```
Profile 'acme-corp-production' is signed in to api.integrator.io, and its OAuth session is sent to no other host — but --base-url points this command at api.eu.integrator.io. Drop --base-url to use the sign-in, or reach api.eu.integrator.io with a profile signed in there (celigo login --profile <name> --base-url https://api.eu.integrator.io) or an API token for it (--token / CELIGO_API_TOKEN).
```

A `base_url` edited by hand after the sign-in is refused the same way, and `celigo config set base_url` (or `config unset base_url`) to another host is refused when written. API tokens are not held to this rule: a token goes wherever `--base-url` or `CELIGO_BASE_URL` points it, so env-only CI jobs are unaffected.

***

## Gotchas

* **Nothing is written until the sign-in succeeds.** A new profile is created in the same write that stores its session, after `GET /v1/tokenInfo` has answered, so an interrupted or failed sign-in leaves no profile behind. A `config.json` that cannot be parsed is refused before the sign-in starts (`Cannot change the configuration: … cannot be read as JSON …`), instead of after a sign-in the CLI would then have to revoke.
* **A refused sign-in revokes its new session.** Whatever refuses a sign-in after the token exchange — a taken name, another environment, a profile holding an API token — revokes the new tokens and leaves `config.json` as it was. A revocation that could not be made is said on stderr (`warning: could not revoke the session at <issuer> (…)`), and the new tokens then stay valid on the server until they expire.
* **Sign-ins from one browser session share one grant.** The platform gives them one OAuth grant, and revoking one session's refresh token revokes the grant. So a `logout`, or a refused sign-in's revocation, can also end other CLI sign-ins made from the same browser session; the CLI names those profiles on stderr (`note: revoking the refused sign-in can also end other CLI sign-ins made from the same browser session, so profile 'acme-corp-sandbox' may need a new sign-in: celigo login --profile acme-corp-sandbox`). For the same reason, `login` never revokes the session it replaces.
* **CI uses an API token.** The device grant waits for a person to approve the code in a browser, so an unattended job cannot complete it. Pass a token from the CI secret store in `CELIGO_API_TOKEN` (with `CELIGO_BASE_URL`); a token wins over any sign-in on the same machine. See [Authenticate](https://developer.celigo.com/cli/getting-started/authenticate.md).
* **Under `profile_pin_policy = strict`.** A `--profile` or `CELIGO_PROFILE` naming an existing profile other than the active one is refused with the policy's refusal, before anything is read or written. A name no profile has yet is not a pin, so `login --profile <new name>` still creates a profile, and a `login` without a name is not a pin either. Under the default `allow`, the same pin prints `celigo: profile 'acme-corp-sandbox' → api.integrator.io (pinned with --profile; the active profile is 'acme-corp-production')` on stderr. See [Refusing a pinned profile](https://developer.celigo.com/cli/getting-started/profiles.md#refusing-a-pinned-profile).
* **The session lives in the config file.** It is the profile's `oauth` block in `~/.celigo/config.json`, which is written owner-only. Every command that prints a profile — `config show`, `config get oauth`, `profile show`, `profile list` — redacts its tokens. See [Security](https://developer.celigo.com/cli/getting-started/authenticate.md#security).

## Related

* [logout](https://developer.celigo.com/cli/commands/logout.md) — revoke a sign-in and forget its tokens.
* [profile](https://developer.celigo.com/cli/commands/profile.md) — `profile add --login`, `profile whoami`, and the profile names `login` shares with `profile add` and `profile rename`.
* [config](https://developer.celigo.com/cli/commands/config.md) — `config get oauth`, and the `base_url` and `api_token` refusals on a signed-in profile.
* [Authenticate](https://developer.celigo.com/cli/getting-started/authenticate.md) — the two credentials side by side, and which one a command uses.
* [Profiles & regions](https://developer.celigo.com/cli/getting-started/profiles.md) — profile names, one credential per profile, and permission modes.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.celigo.com/cli/commands/login.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
