Log in to a Sitecore instance with Sitecore Command Line Interface
How to log in to a Sitecore instance using Sitecore Command Line Interface (CLI).
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:
In PowerShell, go to your Sitecore project folder.
Login with this command:
dotnet sitecore login --authority https://<sitecore-identity-server> --cm https://<sitecore-instance> --allow-write true
The
sitecore login
command opens a login web page in your browser. Enter your username and password and click OK.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:
In PowerShell, go to your Sitecore project folder.
Log in with this command:
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.