Log in to a Sitecore instance with Sitecore Command Line Interface

Current version: 10.0

To log in to a Sitecore instance, Sitecore Command Line Interface (CLI) 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.

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. Login with this command:

    RequestResponse
    dotnet sitecore login --authority https://<sitecore-identity-server> --cm https://<sitecore-instance> --allow-write true
  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.

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

To log in with 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 this command:

    RequestResponse
    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.

Do you have some feedback for us?

If you have suggestions for improving this article,