Friday, April 22, 2022

Sitecore CLI login to multiple environments

 Sitecore CLI login to multiple environments

This post is maybe just for my own reference - but if it helps anyone else it was worth writing it. It's also on Sitecore StackExchange as that will be better indexed probably.

The problem

I was using the Sitecore CLI to login to multiple environments from my local machine. I could successfully login to my local (containerized) instance with a interactive login. I could also login to a remote instance (on Sitecore Managed Cloud). That login was non-interactive.  However, after a login to a remote environment, the local login didn't work anymore.

I was following the official documentation on Sitecore CLI login.

The error

Error while getting client credentials token: invalid_client

 

The solution

Make sure to always provide the --client-credentials argument. Even though it defaults to false and is not mentioned in the docs in the interactive login command, it does fix the issue. If it was set to true before, you need to reset it to false. So for an interactive login, use:

dotnet sitecore login --authority https://<Sitecore identity server> --cm http://<Sitecore instance> --allow-write true --client-credentials false

 



No comments:

Post a Comment