Set up non-interactive client login for Sitecore XM Cloud
Sitecore CLI non-interactive login for the XM world is quite a well known topic since the release of Sitecore 10. On the other hand, for Sitecore XM Cloud it is still a new terrain and there aren't (m)any basic blog posts on first-hand experience setting up the non-interactive client. So, here is that basic toddler-level blog post.
Also, while the Sitecore XM Cloud documentation has good information regarding both interactive and non-interactive login use-cases, this blog post provides a ready-to-use script for non-interactive login + screen shots to setup the Sitecore XM Cloud organization client id and client secret. I've also added a couple of issues I faced while setting up non-interactive login for my Sitecore XM Cloud environment.
As in general terms, interactive login is useful when there is a user who can respond to authentication server login prompt. On the other hand, non-interactive login is useful in case of unattended (scheduled) tasks. Non-interactive login needs a one-time setup so that there is a hand-shake between the client and the Sitecore environment to honor further requests from the client.
Sitecore XMC documentation screen shot regarding scope of the automation clients:
In my case, I wanted to access the XMC deploy environment variables so, organization automation client seems the correct choice.
1. Create Organization automation client to generate the client credentials:
3. Next, execute the PowerShell script that sets up the CLI pre-requisites and does all necessary basic setup by creating the sitecore.json file as well as other necessary folders in one-shot:
6. On the other hand, when i created an environment automation client instead of organization automation client and tried using those client credentials, although the credentials were created for the correct environment, I received the following CLI error since I was trying to access deployment environment variables:
7. If you pass wrong client credentials, you will get a generic unexpected error in the command line:
Comments
Post a Comment