Skip to main content
Level 1
October 15, 2026
Question

Universal Editor Integration in AEM 6.5 LTS

Hi, 

 

I am trying to Integrate Universal Editor with AEM 6.5 LTS. 

I have created a content fragment, a react app. App is able to connect with AEM and the content fragment values are rendering on App. 

But when i try to add the react app url in the Universal Editor console, i am getting following error :

AEM GraphQL error: Error: AEM CSRF response does not contain a token
    at loadFragment (App.jsx:55:17) and this is my app.jsx file :

 

import { useEffect, useState } from 'react'
import './App.css'

const AEM_HOST = 'https://localhost:5502'

const GRAPHQL_URL =
  '/aem/content/cq:graphql/b2bcfconfig/endpoint.json'

const CSRF_URL =
  '/aem/libs/granite/csrf/token.json'

const QUERY = `
  query {
    universalEditorByPath(
      _path: "/content/dam/b2b/contentfragments/ue-demo"
    ) {
      item {
        _path
        title
      }
    }
  }
`

function App() {
  const [fragment, setFragment] = useState(null)
  const [error, setError] = useState('')
  const [loading, setLoading] = useState(true)

  useEffect(() => {
    let cancelled = false

    async function loadFragment() {
      try {
        setLoading(true)
        setError('')

        // Step 1: Get the CSRF token from AEM
        const tokenResponse = await fetch(CSRF_URL, {
          method: 'GET',
          credentials: 'include',
        })

        if (!tokenResponse.ok) {
          throw new Error(
            'CSRF token request failed: ' + tokenResponse.status
          )
        }

        // AEM returns { "token": "..." }
        const tokenData = await tokenResponse.json()
        const csrfToken = tokenData && tokenData.token

        if (!csrfToken) {
          throw new Error(
            'AEM CSRF response does not contain a token'
          )
        }

        console.log('AEM CSRF token retrieved successfully')

        // Step 2: Send the GraphQL query
        const response = await fetch(GRAPHQL_URL, {
          method: 'POST',
          credentials: 'include',
          headers: {
            'Content-Type': 'application/json',
            'CSRF-Token': csrfToken,
          },
          body: JSON.stringify({
            query: QUERY,
          }),
        })

        if (!response.ok) {
          const responseText = await response.text()

          throw new Error(
            'GraphQL request failed: ' +
              response.status +
              (responseText ? ' - ' + responseText : '')
          )
        }

        // Step 3: Read the GraphQL response
        const result = await response.json()

        if (result.errors && result.errors.length > 0) {
          throw new Error(result.errors[0].message)
        }

        const item =
          result.data &&
          result.data.universalEditorByPath &&
          result.data.universalEditorByPath.item

        if (!item) {
          throw new Error(
            'No Content Fragment returned. Check the fragment path and GraphQL query.'
          )
        }

        if (!cancelled) {
          setFragment(item)
        }
      } catch (err) {
        console.error('AEM GraphQL error:', err)

        if (!cancelled) {
          setError(
            err instanceof Error
              ? err.message
              : 'An unexpected error occurred while loading AEM content.'
          )
        }
      } finally {
        if (!cancelled) {
          setLoading(false)
        }
      }
    }

    loadFragment()

    return () => {
      cancelled = true
    }
  }, [])

  return (
    <main className="page">
      <p className="eyebrow">AEM Universal Editor Demo</p>

      {error ? (
        <p role="alert">{error}</p>
      ) : loading ? (
        <p>Loading content from AEM…</p>
      ) : fragment ? (
        <article>
          <h1
            data-aue-resource="urn:aemconnection:/content/dam/b2b/contentfragments/ue-demo/jcr:content/data/master"
            data-aue-prop="title"
            data-aue-type="text"
            data-aue-label="Demo Title"
          >
            {fragment.title || 'Untitled demo fragment'}
          </h1>

          <p>
            Content Fragment path: {fragment._path}
          </p>
        </article>
      ) : null}
    </main>
  )
}

export default App

1 reply

Level 2
October 15, 2026

​@intuitive_Moonbeam2bbf ,

I’d look at the Universal Editor setup for 6.5 LTS first, because this smells like an auth problem in the editor’s iframe. The editor runs on experience.adobe.com, so your app is loaded cross-site. The 6.5 LTS docs say to set the SameSite attribute of the login-token cookie (token.samesite.cookie.attr) on the Adobe Granite Token Authentication Handler to Partitioned, to enable the Query Parameter Authentication Handler by putting “/” in its path, and to set the Universal Editor Opening Mapping. Also double check your meta tags use the aem65 protocol, not aem. Then open the Network tab inside the editor and see what the token.json request actually returns. My guess is it’s coming back anonymous because the cookie isn’t being sent. Longer term, AEM’s docs recommend persisted queries over GET instead of POSTing queries, which would also let you drop the CSRF token step.

Translate