{"id":7775,"date":"2025-04-01T06:34:35","date_gmt":"2025-04-01T06:34:35","guid":{"rendered":"https:\/\/www.qedge.ai\/blog\/?p=7775"},"modified":"2025-04-01T06:35:19","modified_gmt":"2025-04-01T06:35:19","slug":"enabling-and-authorizing-requests-to-the-sitecore-authoring-and-management-api-in-local-docker-development-environment","status":"publish","type":"post","link":"https:\/\/www.qedge.ai\/blog\/enabling-and-authorizing-requests-to-the-sitecore-authoring-and-management-api-in-local-docker-development-environment.html","title":{"rendered":"Enabling and authorizing requests to the Sitecore Authoring and Management API in local Docker development environment"},"content":{"rendered":"\n<div class=\"wp-block-group author\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"100\" height=\"100\" src=\"https:\/\/www.qedge.ai\/blog\/wp-content\/uploads\/2025\/03\/yaochang.png\" alt=\"\" class=\"wp-image-7749\"><\/figure>\n\n\n\n<p><a href=\"https:\/\/www.linkedin.com\/in\/yaochang-liu\/?lipi=urn%3Ali%3Apage%3Ad_flagship3_pulse_read%3BPsC%2FZorIQyW98hDBpLmXrA%3D%3D\" target=\"_blank\" rel=\"noopener\">Yaochang Liu<\/a><\/p>\n\n\n\n<p>Sitecore Technology MVP 2025 | Sitecore Full Specialization Certified Developer (XM Cloud | XP | CDP | Personalize | Content Hub | Order Cloud)<\/p>\n\n\n\n<style>\n.author {\n    max-width: 600px;\n    margin: 2rem auto;\n    padding: 2rem;\n    background: white;\n    border-radius: 12px;\n    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n    text-align: center;\n}\n\n.author .wp-block-image {\n    margin: 0 auto 1.5rem;\n}\n\n.author img {\n    width: 100px;\n    height: 100px;\n    border-radius: 50%;\n    object-fit: cover;\n    border: 3px solid #f0f0f0;\n    transition: transform 0.3s ease;\n}\n\n.author img:hover {\n    transform: scale(1.05);\n}\n\n.author p:first-of-type {\n    font-size: 1.5rem;\n    font-weight: 600;\n    color: #333;\n    margin: 0 0 0.5rem;\n}\n\n.author p:last-of-type {\n    font-size: 0.9rem;\n    color: #666;\n    line-height: 1.5;\n    margin: 0;\n    max-width: 90%;\n    margin: 0 auto;\n}\n\n.wp-block-group__inner-container {\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    gap: 0.5rem;\n}\n<\/style>\n\n\n\n<p><\/p>\n<\/div><\/div>\n\n\n\n<p id=\"ember49\">The Sitecore Authoring and Management GraphQL API is a part of Sitecore's Headless Services, providing a modern, flexible way to interact with Sitecore content. It allows developers to query, create, update, and delete content items using GraphQL queries and mutations. The API is designed to facilitate content management operations, enabling developers to integrate Sitecore content seamlessly into custom front-end applications, headless CMS setups, or other systems. This guide provides instructions on enabling and authoring requests to the API in local Docker environment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ember50\">Enable the GraphQL IDE<\/h2>\n\n\n\n<p id=\"ember51\">Before using the GraphQL IDE, you must enable it in your settings. With the convenience of the Docker environment variables and config files in the Sitecore docker image, you can easily enable it by changing the value of the environment variables.<\/p>\n\n\n\n<p id=\"ember52\">In the Docker compose file, add the following environment variables to <strong>cm<\/strong> service:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ember53\">XM or XP<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">cm:\n    ...\n    environment:\n      ...\n      Sitecore_GraphQL_Enabled: \"true\"\n      Sitecore_GraphQL_ExposePlayground: \"true\"\n      ...<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ember54\">XM Cloud<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">cm:\n    ...\n    environment:\n      ...\n      Sitecore_GraphQL_ExposePlayground: \"true\"\n      ...<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ember55\">Obtain an access token<\/h2>\n\n\n\n<p id=\"ember56\">To authorize the GraphQL IDE or HTTP requests to perform operations against the Authoring and Management API endpoint, you must obtain an access token.<\/p>\n\n\n\n<p id=\"ember57\">To obtain an access token, run the following CLI login command and follow the prompts:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ember58\">XM or XP<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">dotnet sitecore login<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ember59\">XM Cloud<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">dotnet sitecore cloud login<\/pre>\n\n\n\n<p id=\"ember60\">When logged in, the process stores an access token that you can use to set the necessary Authorization header for the GraphQL IDE and HTTP requests. To retrieve the token, open the <strong><em>.\/sitecore\/user.json<\/em><\/strong> file, copy the value of the <strong>accessToken<\/strong> property, and save it for later use.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/media.licdn.com\/dms\/image\/v2\/D5612AQEM9mCh7glEYg\/article-inline_image-shrink_1500_2232\/article-inline_image-shrink_1500_2232\/0\/1729836973640?e=1749081600&amp;v=beta&amp;t=kJsYZouQ6yTk7NkalGJMp8nktXH7PssXqc1ses9EH34\" alt=\"\"><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ember62\">Authorize the GraphQL IDE<\/h2>\n\n\n\n<p id=\"ember63\">Before performing queries and mutations in the GraphQL IDE, you must authorize the IDE to perform operations.<\/p>\n\n\n\n<p id=\"ember64\">To authorize the GraphQL IDE, open the IDE in the browser at the following url:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ember65\">XM or XP<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/&lt;CM_HOST&gt;\/sitecore\/api\/authoring\/graphql\/ide\/<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ember66\">XM Cloud<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/xmcloudcm.localhost\/sitecore\/api\/authoring\/graphql\/ide\/<\/pre>\n\n\n\n<p id=\"ember67\">In the IDE's lower-left pane, the <strong>HTTP Headers<\/strong> tab, add the authorization header with the following format:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n    \"Authorization\": \"Bearer &lt;accessToken&gt;\"\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/media.licdn.com\/dms\/image\/v2\/D5612AQFM2v_ApeH8oA\/article-inline_image-shrink_1500_2232\/article-inline_image-shrink_1500_2232\/0\/1729837270087?e=1749081600&amp;v=beta&amp;t=drYsZJjlvbwMZQt5uu81qOMljN03D85XG7vYiU9Lbx0\" alt=\"\"><\/figure>\n\n\n\n<p id=\"ember70\">Now, you can run the query for authoring and management operations.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/media.licdn.com\/dms\/image\/v2\/D5612AQF0qTpts_uqeQ\/article-inline_image-shrink_1500_2232\/article-inline_image-shrink_1500_2232\/0\/1729838007324?e=1749081600&amp;v=beta&amp;t=KmgGX1KaC09mw4YCV18TN8WurqQ_xScmsMk0KMAGxFs\" alt=\"\"><\/figure>\n\n\n\n<p id=\"ember72\">Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yaochang Liu Sitecore Technology MVP 2025 | Sitecore Full Specialization Certified Developer (XM Cloud | XP | CDP | Personalize | Content Hub | Order Cloud) The Sitecore Authoring and Management GraphQL API is a part of Sitecore's Headless Services, providing a modern, flexible way to interact with Sitecore content. It allows developers to query, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-7775","post","type-post","status-publish","format-standard","hentry","category-insights"],"views":1957,"_links":{"self":[{"href":"https:\/\/www.qedge.ai\/blog\/wp-json\/wp\/v2\/posts\/7775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qedge.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qedge.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qedge.ai\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qedge.ai\/blog\/wp-json\/wp\/v2\/comments?post=7775"}],"version-history":[{"count":2,"href":"https:\/\/www.qedge.ai\/blog\/wp-json\/wp\/v2\/posts\/7775\/revisions"}],"predecessor-version":[{"id":7777,"href":"https:\/\/www.qedge.ai\/blog\/wp-json\/wp\/v2\/posts\/7775\/revisions\/7777"}],"wp:attachment":[{"href":"https:\/\/www.qedge.ai\/blog\/wp-json\/wp\/v2\/media?parent=7775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qedge.ai\/blog\/wp-json\/wp\/v2\/categories?post=7775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qedge.ai\/blog\/wp-json\/wp\/v2\/tags?post=7775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}