---
title: "Log in to a Sitecore instance with Sitecore Command Line Interface"
slug: "log-in-to-a-sitecore-instance-with-sitecore-command-line-interface"
abstract: "How to log in to a Sitecore instance using Sitecore Command Line Interface (CLI)."
---
# Log in to a Sitecore instance with Sitecore Command Line Interface

To log in to a Sitecore instance, [Sitecore Command Line Interface (CLI)](https://doc.sitecore.com/xp/en/developers/103/developer-tools/sitecore-command-line-interface.html "Sitecore Command Line Interface") allows two flows of authentication and authorization:

- An interactive user login, using a device code flow.
- A non-interactive client login, using a client credentials flow. This is used by clients such as Continuous Integration servers.

> [!important]
> Sitecore CLI requires the use of [Sitecore Identity](https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-manager/sitecore-identity.html).

## Use an interactive user login (device code flow)

To log in with an interactive user login to a Sitecore instance, you must have the following:

- The URL of the Sitecore Identity Server.
- The URL of the Sitecore instance.
- Your username.
- Your password.

To log in:

1. In PowerShell, go to your Sitecore project folder.
2. Log in with the following command:

    ```text
    dotnet sitecore login --authority https://<sitecore-identity-server> --cm https://<sitecore-instance> --allow-write true --client-id <client-id>
    ```

    > [!note]
    > The default client ID is `Device`.

3. The `sitecore login` command opens a login web page in your browser. Enter your username and password and click **OK**.
4. The `sitecore login` command stores your login arguments in the `.sitecore\user.json` file together with an access token. You are now logged in, and you can close the login web page.

    > [!important]
    > Do not commit the `.sitecore/user.json` file to source control as it contains privileged information.

> [!tip]
> After logging in with the device flow, you can switch to the client credentials flow by running the command:
>
> dotnet sitecore login --client-id <client-id> --client-secret <client-secret> --client-credentials true

## Use a non-interactive client login (client credentials flow)

To log in with a [non-interactive client login](https://doc.sitecore.com/xp/en/developers/103/developer-tools/configure-a-non-interactive-client-login.html "Configure a non-interactive client login") to a Sitecore instance, you must have the following:

- The URL of the Sitecore Identity Server.
- The URL of the Sitecore instance.
- The client ID.
- The client secret.

To log in:

1. In PowerShell, go to your Sitecore project folder.
2. Log in with the following command:

    ```text
    dotnet sitecore login --authority https://<sitecore-identity-server> --cm http://<sitecore-instance> --allow-write true --client-credentials true --client-id <client-id> --client-secret <client-secret>
    ```

> [!note]
> Run the `dotnet sitecore login --help` command for more details on the login command.

> [!tip]
> After logging in with the client credentials flow, you can switch to the device flow by running the following command:
>
> dotnet sitecore login  --client-credentials false --client-id <client-id>
>
> The default client ID is `Device`.