---
title: "The CLI login command"
slug: "the-cli-login-command"
abstract: "Describes the DevEx CLI login command that authorizes plugins containing additional CLI commands to perform operations in a Sitecore instance."
---
# The CLI login command

The [Sitecore CLI](https://doc.sitecore.com/xp/en/developers/104/developer-tools/sitecore-command-line-interface.html "Sitecore Command Line Interface") includes a `login` command that allows developers to log in to a Sitecore instance.

> [!note]
> To authenticate against a Sitecore Experience Manager (XM) Cloud instance, use the [`cloud login` command provided by the XM Cloud plugin](https://doc.sitecore.com/xmc/en/developers/xm-cloud/en/the-cloud-login-command.html).

<details>
<summary><h2>Usage</h2></summary>

The Sitecore CLI `login` command is initiated within the Sitecore CLI by using the following:

```shell
dotnet sitecore login [options]

```

</details>

<details>
<summary><h2>Options</h2></summary>

You can use the following options with the `login` command:

| Option | Required | Description |
| --- | --- | --- |
| `--authority, --auth` | No | Identity authority for the environment, such as identity server or AAD tenant URL. |
| `--audience` | No | The unique identifier of the audience that issued the token. |
| `--environment, -n` | No | Named Sitecore environment to use. Default: `'default'`. |
| `--cm` | No | Sitecore content management hostname to connect to. |
| `--allow-write` | No | Enable writing data to the environment. |
| `--client-credentials` | No | Use client credentials (for CI/CD, shared secret). |
| `--client-id` | No | The OAuth ClientID to send. Defaults to `'Device'` for device auth, and `'SitecoreCLIServer'` for client credentials. |
| `--client-secret` | No | The OAuth client secret to send. Only used for client credentials authentication. |
| `--config, -c` | No | Path to the root `sitecore.json` directory. Default: current working directory. |
| `--help, -h, -?` | No | Display developer help and usage information about the command. |
| `--trace, -t` | No | Outputs additional diagnostics and detailed information about the command. |
| `--insecure, -k` | No | Allows using an insecure (`http`) authority URL. Only applicable with the client credentials flow (`--client-credentials true`). Available in version 4.1.0 and later. |
| `--ref, -r` | No | Log in to an existing environment and use its credentials. Requires that you provide the `--cm` and `--allow-write` parameters.<br><br>For example: `dotnet sitecore login --ref <your environment> --cm https://<sitecore instance> --allow-write true`. |

</details>

<details>
<summary><h2>Examples</h2></summary>

The following are examples of using the `login` command for interactive user login:

- Command: Result
- dotnet sitecore login --authority https://<sitecore identity server> --cm https://<sitecore instance> --allow-write truedotnet sitecore login: Output:

```shell
Logging in to Sitecore. You should see a browser window open shortly.
[DeviceLogin] User Code : 1234
[DeviceLogin] Authentication url : https://<sitecore identity server>/device?userCode=1234
[DeviceLogin] Authorization pending. Waiting.
[DeviceLogin] Authorization pending. Waiting.
Your login is complete. You can close the browser tab now.
Login information has been saved.

```

The following are examples of using the `login` command for noninteractive user login:

- Command: Description
- dotnet sitecore login --authority https://<sitecore identity server> --cm https://<sitecore instance> --allow-write true --client-credentials true --client-id <client id> --client-secret <client secret>: Use the [non-interactive client login](https://doc.sitecore.com/xp/en/developers/104/developer-tools/configure-a-non-interactive-client-login.html).
- dotnet sitecore login --cm https://<sitecore instance> --auth http://<sitecore identity server> --allow-write true --client-id <client id> --client-secret <client secret> --client-credentials true --insecure: Bypass the `https` protocol restriction.

For more information, refer to [logging in to a Sitecore instance using the CLI](https://doc.sitecore.com/xp/en/developers/104/developer-tools/log-in-to-a-sitecore-instance-with-sitecore-command-line-interface.html "Log in to a Sitecore instance with Sitecore Command Line Interface").

</details>