0

I'm trying to use the example /sitecore/api/graph/items/master endpoint for Sitecore GraphQL, which uses the systemService security configuration. However when I visit /sitecore/api/graph/items/master/ui, I get an Authentication required error. I am logged into Sitecore and can access the Launchpad and Content Editor. How can I use this GraphQL example and systemService?

1 Answer 1

3

When using Sitecore Identity Service for login (default on Sitecore 9.1+), you must configure additional URLs for which Sitecore will apply authentication cookies. For this example, a configuration patch on your CM such as the following would accomplish this:

<configuration>
  <sitecore>
    <pipelines>
      <owin.cookieAuthentication.validateIdentity>
        <processor type="Sitecore.Owin.Authentication.Pipelines.CookieAuthentication.ValidateIdentity.ValidateSiteNeutralPaths, Sitecore.Owin.Authentication">
          <siteNeutralPaths hint="list">
             <path hint="graphql">/sitecore/api/graph/items/</path>
          </siteNeutralPaths>
        </processor>
      </owin.cookieAuthentication.validateIdentity>
    </pipelines>
  </sitecore>
</configuration>

Additionally, if using Headless Services 18.0+, the new GraphQL Playground IDE used for the GraphQL UI will not pass cookies by default. In the Settings (accessible via the gear icon the upper right corner), change request.credentials to same-origin and click Save Settings.

Settings with request.credentials

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.