Authentication & profiles

The CLI authenticates to CARTO with an OAuth 2.0 + PKCE browser flow. The first time you run carto auth login, the CLI opens your browser, you complete the standard CARTO login (including SSO if your organization requires it), and the CLI captures the resulting access token and stores it locally.

Logging in

# Interactive browser-based login (recommended)
carto auth login

# Login to a named profile
carto auth login staging

The login flow:

  1. Displays an authorization URL.

  2. Opens your browser (you may need to copy/paste the URL manually in headless environments).

  3. Waits for you to complete the login.

  4. Captures the access token and your user/organization info.

  5. Stores the credentials in ~/.carto_credentials.json.

  6. Configures the API base URL based on your tenant.

Logging in to a specific organization (with or without SSO)

If your organization uses SSO, or if you have access to multiple organizations, log in with the organization name:

How it works:

  1. The CLI queries your organization's SSO configuration from the CARTO API.

  2. If SSO is configured: the browser opens to your organization's SSO login page (SAML/OIDC).

  3. If SSO is not configured: standard OAuth login proceeds.

  4. The organization context is preserved for re-authentication.

Requirements:

  • Use the exact organization name (case-sensitive, include spaces in quotes).

  • For SSO logins, your organization administrator must have configured SSO in CARTO.

Auth login options

Option
Description

--env <environment>

Auth environment: production, staging, local, dedicated-NN. Only set this if instructed by support.

--organization-name <name>

Organization name for SSO login. Use quotes if the name contains spaces.

--organization-id <id>

Organization ID for SSO login (future support).

Checking status

Example output:

carto auth whoami returns the current user's profile (user ID, name, email, account info, roles).

Token lifetime and re-authentication

Access tokens typically expire after 24 hours. The CLI extracts the expiration from the JWT and surfaces it in carto auth status:

Indicator
Meaning

🟢 Valid

More than 10% of token lifetime remaining.

🟡 Expiring soon

Less than 10% of lifetime remaining (~2.4 hours for a 24-hour token).

🔴 Expired

Token has expired and must be renewed.

When a token is expiring or expired, the CLI suggests a context-aware re-authentication command that preserves your profile, environment, and (if applicable) organization name — so you don't accidentally create a duplicate profile or end up in the wrong environment.

Logging out

This removes the stored credentials for that profile.

Multiple profiles

Use named profiles when you work with more than one CARTO organization (production vs. staging, multiple customer accounts, multiple regions, …). Each profile holds its own credentials and tenant configuration.

A profile represents authentication to a specific:

  • Tenant (infrastructure region) — e.g. gcp-us-east1, onp-acme-prod (self-hosted).

  • Organization (account) — e.g. team, carto-prod.

  • User (authenticated user) — e.g. [email protected].

carto auth status (with no arguments) shows the full hierarchy: tenant → organization → user, plus all available profiles with the current default marked.

Profile management notes:

  • Auto-generated names — Login without a name suggests profiles in the format tenant_id/org_name/[email protected].

  • Custom names — Provide a short name during login (e.g., staging, production).

  • Current profile — The default used when --profile is not specified.

  • Override per command — Use --profile <name> on any command, or set CARTO_PROFILE in the environment.

  • Backwards compatibility — Old single-profile credentials files are migrated automatically on first use.

For a detailed walkthrough of using profiles to copy maps and workflows between organizations, see Examples → Copying maps and workflows between organizations.

Credentials storage

See Configuration for the credentials file format, environment variables, and authentication priority.

Last updated

Was this helpful?