---
title: auth command group
description: Learn how to set up the Databricks CLI to use Databricks authentication with OAuth.
canonical_url: https://docs.databricks.com/aws/en/dev-tools/cli/reference/auth-commands
---

# `auth` command group

> [!NOTE]
>
> Databricks CLI use is subject to the [Databricks License](https://github.com/databricks/cli?tab=License-1-ov-file#readme) and [Databricks Privacy Notice](https://www.databricks.com/legal/privacynotice), including any Usage Data provisions.

The `auth` command group within the [Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/index.md) contains authentication related commands, including the following:

* List any available authentication configuration profiles.
* Get information about an individual authentication configuration profile.
* Use OAuth user-to-machine (U2M) authentication to authenticate the Databricks CLI with your Databricks accounts and workspaces.
* Log out of a profile by clearing cached OAuth tokens and optionally removing the profile entry.
* Get information about any OAuth access tokens that the Databricks CLI might have cached.
* Get details about the configuration that the Databricks CLI is using to authenticate.

> [!TIP]
>
> To get information about the current Databricks CLI user, run `databricks current-user me`.

## databricks auth describe

Describes the configuration that the Databricks CLI is using to authenticate, including the credentials and the source of those credentials. If no options are specified, the `auth describe` command follows the [Authentication method priority](https://docs.databricks.com/aws/en/dev-tools/auth/unified-auth.md#order-of-eval).

```
databricks auth describe [flags]
```

#### Options

**`--sensitive`**

    Include sensitive fields like passwords and tokens in the output

[Global flags](https://docs.databricks.com/aws/en/dev-tools/cli/reference/auth-commands.md#global-flags)

#### Examples

The following example describes the current authentication configuration:

```bash
databricks auth describe
```

```Output
Host: https://<workspace-instance-name>
User: <user-name>@<domain>
Authenticated with: <authentication-type>
-----
Current configuration:
  ✓ host: https://<workspace-instance-name> (from <path>/<to>/.databrickscfg config file)
  ✓ profile: default
  ✓ auth_type: <authentication-type> (from <path>/<to>/.databrickscfg config file)
```

To specify that information about a specific Databricks workspace is used, specify the `--host` option along with the workspace's URL.

```bash
databricks auth describe --host https://<workspace-instance-name>
```

```Output
Host: https://<workspace-instance-name>
User: <user-name>@<domain>
Authenticated with: <authentication-type>
-----
Current configuration:
  ✓ host: https://<workspace-instance-name> (from --host flag)
  ✓ profile: default
  ✓ auth_type: <authentication-type>
```

To specify that information about a specific Databricks account is used, specify the `--host` option along with the Databricks account console URL, [https://accounts.cloud.databricks.com](https://accounts.cloud.databricks.com).

```bash
databricks auth describe --host <account-console-url>
```

```Output
Host: <account-console-url>
User: <user-name>@<domain>
AccountId: <account-id>
Authenticated with: <authentication-type>
-----
Current configuration:
  ✓ host: <account-console-url> (from --host flag)
  ✓ account_id: <account-id>
  ✓ profile: default
  ✓ auth_type: <authentication-type>
```

To specify that information about a specific Databricks configuration profile is used, specify the `-p` or `--profile` option along with the profile's name:

```bash
databricks auth describe -p TEST
```

```Output
Host: https://<workspace-instance-name>
User: <user-name>@<domain>
Authenticated with: <authentication-type>
-----
Current configuration:
  ✓ host: https://<workspace-instance-name> (from <path>/<to>/.databrickscfg config file)
  ✓ token: ******** (from <path>/<to>/.databrickscfg config file)
  ✓ profile: TEST (from --profile flag)
  ✓ auth_type: <authentication-type>
```

To include sensitive information in the output (such as Databricks personal access tokens and client secrets), specify the `--sensitive` option:

```bash
databricks auth describe --sensitive
```

```Output
Host: https://<workspace-instance-name>
User: <user-name>@<domain>
Authenticated with: pat
-----
Current configuration:
  ✓ host: https://<workspace-instance-name> (from <path>/<to>/.databrickscfg config file)
  ✓ token: <token-value> (from <path>/<to>/.databrickscfg config file)
  ✓ profile: <profile-name>
  ✓ auth_type: pat
```

## <a id="get-config-profile" />databricks auth env

> [!WARNING]
>
> This command is deprecated.

Get information about an existing configuration profile using the name of the profile or the Databricks account console URL or the Databricks workspace URL.

```
databricks auth env [flags]
```

> [!TIP]
>
> You can press `Tab` after `--profile` or `-p` to display a list of existing available configuration profiles to choose from, instead of entering the configuration profile name manually.

To create a configuration profile, see the [`configure` command](https://docs.databricks.com/aws/en/dev-tools/cli/reference/configure-commands.md).

#### Options

**`--host string`**

    Hostname to get auth env for

> [!NOTE]
>
> If more than one profile matches the `--host` value, an error displays, stating that it cannot find a single matching profile. For example, you might have one profile that has only a host value and another profile that has the same host value but also a token value. In this case, the Databricks CLI does not choose a profile and stops. To help the Databricks CLI choose the desired profile, try specifying a different `--host` value. For `--host` values that are account console URLs, try specifying an `--account-id` value instead of a `--host` value.

**`--profile string`**

    Profile to get auth env for

[Global flags](https://docs.databricks.com/aws/en/dev-tools/cli/reference/auth-commands.md#global-flags)

#### Examples

The following example gets the default authentication environment:

```bash
databricks auth env
```

The following example gets the authentication environment for a specific host:

```bash
databricks auth env --host https://my-workspace.cloud.databricks.com
```

The output for a profile that is configured with Databricks access token authentication might be:

```json
{
  "env": {
    "DATABRICKS_AUTH_TYPE": "pat",
    "DATABRICKS_CONFIG_PROFILE": "TEST",
    "DATABRICKS_HOST": "https://my-workspace.cloud.databricks.com",
    "DATABRICKS_TOKEN": "<token-value>"
  }
}
```

The following example gets the authentication environment for a specific profile:

```bash
databricks auth env --profile my-test-environment
```

## databricks auth login

Log in to a Databricks workspace or account and save the authentication configuration in a profile (in `~/.databrickscfg` by default). The profile can then be used to authenticate other Databricks CLI commands using the `--profile` flag. The profile can also be used to authenticate other Databricks tools that support Databricks unified authentication, including the Databricks Python, Java, and Go SDKs.

```
databricks auth login HOST [flags]
```

This command requires a Databricks host URL (using `--host` or as a positional argument or implicitly inferred from the specified profile name) and a profile name (using `--profile`) to be specified. If you don't specify these values, you'll be prompted for values at runtime.

While this command always logs you into the specified host, the behavior depends on the existing profiles you have set in your configuration file (at `~/.databrickscfg` by default):

1. If a profile with the specified name exists and specifies a host, you'll be logged into the host specified by the profile. The profile will be updated to use "databricks-cli" as the auth type if that was not the case before.
2. If a profile with the specified name exists but does not specify a host, you'll be prompted to specify a host. The profile will be updated to use the specified host. The auth type will be updated to "databricks-cli" if that was not the case before.
3. If a profile with the specified name exists and specifies a host, but you specify a host using `--host` (or as the `HOST` positional arg), the profile will be updated to use the newly specified host. The auth type will be updated to "databricks-cli" if that was not the case before.
4. If a profile with the specified name does not exist, a new profile will be created with the specified host. The auth type will be set to "databricks-cli".

#### Arguments

**`HOST`**

    Databricks host URL (optional)

#### Options

**`--configure-cluster`**

    Prompts to configure cluster (classic compute)

**`--configure-serverless`**

    Prompts to configure serverless compute

**`--timeout duration`**

    Timeout for completing login challenge in the browser (default 1h0m0s)

[Global flags](https://docs.databricks.com/aws/en/dev-tools/cli/reference/auth-commands.md#global-flags)

#### Examples

The following example logs into a Databricks workspace:

```bash
databricks auth login
```

The following example logs into a specific Databricks workspace:

```bash
databricks auth login https://my-workspace.cloud.databricks.com
```

The following example logs in with a specific profile and configures cluster settings:

```bash
databricks auth login --profile my-profile --configure-cluster
```

The following example sets a custom timeout for the login process:

```bash
databricks auth login --timeout 30m
```

## databricks auth logout

Log out of a Databricks profile by clearing its cached OAuth tokens. You will need to run `databricks auth login` to re-authenticate. The profile remains in the configuration file (`~/.databrickscfg` by default) unless you also specify `--delete`.

```
databricks auth logout [PROFILE] [flags]
```

This behavior applies only to profiles created with `databricks auth login` (`auth_type` set to `databricks-cli`). Profiles that use other authentication methods, such as personal access tokens or machine-to-machine credentials, do not store cached OAuth tokens, so there is nothing to clear. If multiple profiles share the same cached token, logging out of one does not affect the others.

Command behavior:

1. If you specify a profile (as the `PROFILE` argument or with `--profile`), the command logs out of that profile. You can also provide a host URL, which the command resolves to the matching profile. In an interactive terminal, it asks for confirmation unless you also specify `--auto-approve`.
2. If you omit the profile in an interactive terminal, the command shows a searchable profile picker. You can search by profile name, host, or account ID. After you select a profile, the command asks for confirmation unless you also specify `--auto-approve`.
3. If you omit the profile in a non-interactive environment, the command fails and asks you to specify a profile.
4. In a non-interactive environment, specify a profile together with `--auto-approve` to skip confirmation.

#### Arguments

**`PROFILE`**

    Profile name or host URL to log out of (optional). The argument is first matched against existing profile names. If no profile matches and the argument looks like a host URL, the command resolves it to the profile(s) configured for that host. If multiple profiles match a host, the command prompts you to select one (or errors in non-interactive mode).

#### Options

**`--delete`**

    Also remove the profile from the configuration file (`~/.databrickscfg` by default)

**`--auto-approve`**

    Skip the confirmation prompt

[Global flags](https://docs.databricks.com/aws/en/dev-tools/cli/reference/auth-commands.md#global-flags)

#### Examples

The following example logs out of a specific profile:

```bash
databricks auth logout my-profile
```

The following example logs out of the profile associated with a host URL:

```bash
databricks auth logout https://my-workspace.cloud.databricks.com
```

The following example logs out and removes the profile from the configuration file:

```bash
databricks auth logout --profile my-profile --delete
```

The following example logs out without a confirmation prompt, suitable for CI/CD:

```bash
databricks auth logout my-profile --auto-approve
```

## databricks auth profiles

List all available configuration profiles (at `~/.databrickscfg` by default) and check whether they are valid profiles.

```
databricks auth profiles [flags]
```

This command outputs profiles in the following format:

```
Name            Host                Valid
DEFAULT         https://<host-url>  YES
<profile-name>  https://<host-url>  NO
```

To determine whether each profile is valid, the Databricks CLI lists workspaces for each account-level profile and runs a get current user command for each workspace-level profile. If the command succeeds, a `YES` is displayed; otherwise, a `NO` displays.

The output of the `auth profiles` command does not display any access tokens. To display an access token, see [databricks auth env](https://docs.databricks.com/aws/en/dev-tools/cli/reference/auth-commands.md#get-config-profile).

By default, configuration profiles are stored in the file `~/.databrickscfg` on Linux or macOS, or `%USERPROFILE%\.databrickscfg` on Windows. You can change the default path of this file by setting the environment variable `DATABRICKS_CONFIG_FILE`.

To create configuration profiles, see the [`configure` command](https://docs.databricks.com/aws/en/dev-tools/cli/reference/configure-commands.md).

#### Options

**`--skip-validate`**

    Whether to skip validating the profiles

[Global flags](https://docs.databricks.com/aws/en/dev-tools/cli/reference/auth-commands.md#global-flags)

#### Examples

The following example lists all authentication profiles:

```bash
databricks auth profiles
```

The following example lists profiles without validating them:

```bash
databricks auth profiles --skip-validate
```

## <a id="switch" />databricks auth switch

Set a named profile as the default in `~/.databrickscfg`. The selected profile name is stored in a `[__settings__]` section in the config file under the `default_profile` key. Use `databricks auth profiles` to see which profile is currently the default.

```
databricks auth switch [flags]
```

#### Options

[Global flags](https://docs.databricks.com/aws/en/dev-tools/cli/reference/auth-commands.md#global-flags)

#### Examples

The following example interactively selects a profile to set as the default:

```bash
databricks auth switch
```

The following example sets a specific profile as the default:

```bash
databricks auth switch --profile my-profile
```

## <a id="oauth-auth" />databricks auth token

Get the authentication token from the local cache in `~/.databricks/token-cache.json`. Refresh the access token if it is expired or close to expiry. This command only works with U2M authentication (using the `databricks auth login` command). M2M authentication using a client ID and secret is not supported.

```
databricks auth token [HOST_OR_PROFILE] [flags]
```

To configure and set up OAuth U2M authentication, see [OAuth user-to-machine (U2M) authentication](https://docs.databricks.com/aws/en/dev-tools/cli/authentication.md#u2m-auth).

#### Arguments

**`HOST_OR_PROFILE`**

    Databricks host URL or profile name (optional)

#### Options

**`--account-id string`**

    Databricks Account ID

**`--force-refresh`**

    Force a token refresh even if the cached token is still valid.

**`--timeout duration`**

    Timeout for acquiring a token. (default 1h0m0s)

[Global flags](https://docs.databricks.com/aws/en/dev-tools/cli/reference/auth-commands.md#global-flags)

#### Examples

The following example gets the authentication token:

```bash
databricks auth token
```

The following example gets the authentication token for a specific host:

```bash
databricks auth token https://my-workspace.cloud.databricks.com
```

The output might be:

```json
{
  "access_token": "<token-value>",
  "token_type": "Bearer",
  "expiry": "<token-expiration-date-time>"
}
```

The following example sets a custom timeout for token acquisition:

```bash
databricks auth token --timeout 30m
```

## <a id="global-flags" />Global flags

**`--debug`**

  Whether to enable debug logging.

**`-h` or `--help`**

    Display help for the Databricks CLI or the related command group or the related command.

**`--log-file` string**

    A string representing the file to write output logs to. If this flag is not specified then the default is to write output logs to stderr.

**`--log-format` format**

    The log format type, `text` or `json`. The default value is `text`.

**`--log-level` string**

    A string representing the log format level. If not specified then the log format level is disabled.

**`-o, --output` type**

    The command output type, `text` or `json`. The default value is `text`.

**`-p, --profile` string**

    The name of the profile in the `~/.databrickscfg` file to use to run the command. If this flag is not specified then if it exists, the profile named `DEFAULT` is used.

**`--progress-format` format**

    The format to display progress logs: `default`, `append`, `inplace`, or `json`

**`-t, --target` string**

    If applicable, the bundle target to use
