1

I'm at the early stages of trying to figure out the Drupal JSON API and can't figure out what's causing the following errors.

Some resources have been omitted because of insufficient authorization.

The current user is not allowed to GET the selected resource in the response.

Is there a header I should use? It's all local so there's no basic auth to get past.

The code I am using is the following one.

  fetch('http://localhost/domain-6/jsonapi/group_content/microsite-group_menu-main', {
    method: 'GET',
    mode: 'no-cors',
    headers: {
      'Accept': 'application/vnd.api+json',
      'Content-Type': 'application/vnd.api+json'
    }
  })
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch((error) => {
    console.error('Error: ', error);
  });

The response I get is the following one.

{"jsonapi":{"version":"1.0","meta":{"links":{"self":{"href":"http:\/\/jsonapi.org\/format\/1.0\/"}}}},"data":[],"meta":{"omitted":{"detail":"Some resources have been omitted because of insufficient authorization.","links":{"help":{"href":"https:\/\/www.drupal.org\/docs\/8\/modules\/json-api\/filtering#filters-access-control"},"item--XQp4cup":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/470ce30a-b29a-440c-9dfd-62ec2ecc2174","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--1lQ8DZL":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/fd53a4be-b3b3-4fba-8739-fe10bf3594b5","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--CMmFdif":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/44e9ad5d-f644-49d4-9b06-8393fe9f179b","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--35OuqGr":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/993f1dd0-7479-42f2-8cdb-4ad37f69b08d","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--S9wgeIz":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/5d327513-431a-47fc-ad60-7d118cb75e28","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--GadCb5C":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/73420f3a-f77b-40bc-b72c-0529c7c4a7e0","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--whX9lWC":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/186316e4-42a5-4551-b3e3-f2d8d0c924b3","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--0ZPeOPd":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/2b309be4-721d-4000-ab31-811b4c04b15e","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--rMyrlTp":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/bdfc8224-04a9-4795-add5-f363c2433229","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--59LnH0e":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/c5dcd0f8-b594-4567-b15f-a0a64b5186b7","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--3WKSiq1":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/9e76a2a3-e121-4650-b83e-f9425c17a4bf","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--jjQ9TP2":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/ae2b6217-be02-49de-9e01-b6c4a9b67e72","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--dhiafhE":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/61119a05-877c-44c8-940b-fab317c0dc5d","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--c7850PO":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/d636ea7f-f453-47e5-9536-c2b8f3f50c92","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--ngkUSZk":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/a0f48948-e846-4d23-9bbf-4d4b7ccc3507","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--2oP7rlR":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/a6625804-294c-493b-a904-fb1f561573c6","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--Sz5wBPb":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/267f6042-ad6e-411e-8925-006877a7c9ad","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--tMDa2oF":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/ccf1fd6a-921e-4144-97bf-e7d85b4dbdf8","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--vYs3zKx":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/7187c2ba-6ee7-435c-9166-3fc0ce8fb421","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--5vJmCru":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/10ba20cc-f0b6-4365-9b34-221452e4a0fc","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--23KRMeA":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/5096f25f-4359-4cb7-9ec0-335b088d24bd","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--exhD7mi":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/be7d1151-8f65-4eef-8fdc-a936a6cde937","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--UISA0FF":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/89fdb64c-6e33-4237-8137-fad965fb7614","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--Fzg9qbP":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/b69894a9-e7b0-4d63-aecb-069ae054c09f","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--qPBbJA1":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/ae6d8f9b-0725-4fee-9c5d-cd25c8bbe583","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--EqTCJ1N":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/f6c7d183-ff1a-497c-9dac-51d7bd927150","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--uF6v1TR":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/b2db9f2e-1907-4fdf-aa49-1370d0bcf54d","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--MV28pBq":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/8313b799-5f10-4416-ba20-49c2de2834a9","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--wVd7rsP":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/346bdf69-93ec-4127-a483-e7d687b20e2d","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--h0VjXuJ":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/052730d5-18f5-47fb-834f-8ed6898031e1","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--fcA5aED":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/fcdebbce-047b-4cfa-a185-67ae7e01262c","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--3dDdcIg":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/450b3119-4d70-41ee-aecf-6ffe77e76f71","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--3XlVwNC":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/917f9200-6a48-40e2-9c56-e3834fe392f3","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--QtN7OYa":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/de886c77-ebd0-41de-a4ee-872113f6afec","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--Q6uGw9H":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/9ede015d-28b5-4e61-a3ad-1a65b0527f34","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--qwxls5H":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/f12a3922-26c2-47b1-8e62-ff7efb9b005a","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--ngPbsJJ":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/e4540be8-f206-46de-94a6-57a5f7b20ab3","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--AnR0WT0":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/2d0a7020-11d4-4536-a446-fc8450a31559","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--AhzT8c6":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/402e1e71-ec7c-46c4-bc5b-a3b925df70b4","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--Wm2v9pb":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/4f475314-c892-43ab-bb0f-5e1d265cc4d0","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--kd0J901":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/78909988-22e9-491d-a47e-229c0a7a225e","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--404rztx":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/a13ff285-dfda-4949-b85d-67af424fdc92","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--G4zUasD":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/afc8da9b-b945-4013-b4e6-7cfda013b57c","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--hC13Nrz":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/61c25a67-06ed-4831-8f25-e4849632a91e","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--PWp8vHM":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/7c3fa94e-4d4c-4a74-b5ee-8909d2481054","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--Nzyn35g":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/cd43deee-5f44-4f23-9708-58163cd8150d","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--IZapjnH":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/5fc7df8b-1429-4c05-b0d0-6042f53992ad","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--Tf1PVbP":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/ae718931-248f-4d8f-9923-626445d66056","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--WIAJdC5":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/804424f6-bf31-4689-a935-dd92082325e2","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}},"item--g2Rs5um":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main\/24d7998f-eca9-4c7e-9ddc-f544e0cab691","meta":{"rel":"item","detail":"The current user is not allowed to GET the selected resource."}}}}},"links":{"next":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main?page%5Boffset%5D=50\u0026page%5Blimit%5D=50"},"self":{"href":"http:\/\/localhost\/domain-6\/jsonapi\/group_content\/microsite-group_menu-main"}}}
2
  • The answer below is probably correct, but it's unclear what "it's all local" means. Does that mean the browser is fetching from the same origin? Cross-origin?
    – mradcliffe
    Nov 11, 2020 at 18:42
  • The Drupal site and the site that consume the API are both on localhost. Nov 13, 2020 at 10:07

1 Answer 1

1

probably no access due to the fact that:

"fetch won’t send cookies"

https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch

1
  • I added credentials: include to the fetch options object but that didn't work. Nov 13, 2020 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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