The CLI login command

Version:

The Sitecore CLI includes a login command that allows developers to log into a Sitecore instance.

Note

Sitecore CLI login command requires the use of Sitecore Identity.

Usage

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

dotnet sitecore login [options]

Options

You can use the following options with the login command:

OptionRequired?Description
--authority, --authNoIdentity authority for the environment, such as identity server or AAD tenant URL.
--environment, -nNoNamed Sitecore environment to use. Default: 'default'.
--cmNoSitecore content management hostname to connect to.
--allow-writeNoEnable writing data to the environment.
--client-credentialsNoUse client credentials (for CI/CD, shared secret).
--client-idNoThe OAuth ClientID to send. Defaults to 'Device' for device auth, and 'SitecoreCLIServer' for client credentials.
--client-secretNoThe OAuth client secret to send. Only used for client credentials authentication.
--config, -cNoPath to the root sitecore.json directory. Default: current working directory.
--help, -h, -?NoDisplay developer help and usage information about the command.
--trace, -tNoOutputs additional diagnostics and detailed information about the command.

Examples

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

  • Command: Result
  • dotnet sitecore login --authority https:// --cm http:// --allow-write truedotnet sitecore login: Output:

Logging in to Sitecore. You should see a browser window open shortly.
[DeviceLogin] User Code : 1234
[DeviceLogin] Authentication url : https://id.[host].localhost/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 non-interactive user login:

  • Command: Description
  • dotnet sitecore login --authority https:// --cm http:// --allow-write true --client-credentials true --client-id --client-secret : Use the non-interactive client login.

For more information, refer to logging in to a Sitecore instance using the CLI.

If you have suggestions for improving this article, let us know!