GraqphQL returns Forbidden response besides following all tutorial steps. Help!

System Information
  • Strapi Version: v3.6.8 Community
  • Operating System: CentOS7
  • Database: Mongo
  • Node Version: v14.17.6
  • NPM Version:
  • Yarn Version:

I am trying to get the GraphQL integration working.
I followed these steps:

  • create user in Strapi (tried also creating through the GraqhQL register call) both works
  • make sure the user has proper CRUD permissions to all relevant content types (works)
  • do a login call through the GraphQL to get authentication token (works)
  • put Authentication Token as HTTP header into the playground tool (works)
  • run a simple query e.g. the following

query {
users(where: { id_gt: “0” }) {
email
}
}

Error response is Error:Forbidden — see below. I am on the community version - is that the problem? Confirming the obvious checks have bee done on adding the authentication token with the request and making sure content type permissions are being set. Also tried querying other content types with the same response. Where do I go from here?

{
“errors”: [
{
“message”: “Forbidden”,
“locations”: [
{
“line”: 2,
“column”: 3
}
],
“path”: [
“users”
],
“extensions”: {
“code”: “INTERNAL_SERVER_ERROR”,
“exception”: {
“data”: null,
“isBoom”: true,
“isServer”: false,
“output”: {
“statusCode”: 403,
“payload”: {
“statusCode”: 403,
“error”: “Forbidden”,
“message”: “Forbidden”
},
“headers”: {}
},
“message”: “Forbidden”,
“stacktrace”: [
“Error: Forbidden”,
" at handleErrors (/my-project/node_modules/strapi-plugin-users-permissions/config/policies/permissions.js:92:28)",
" at module.exports (/my-project/node_modules/strapi-plugin-users-permissions/config/policies/permissions.js:79:12)",
" at async /my-project/node_modules/strapi-utils/lib/policy.js:68:5",
" at async /my-project/node_modules/strapi-plugin-graphql/services/resolvers-builder.js:114:5",
" at async /my-project/node_modules/strapi-plugin-graphql/services/shadow-crud.js:87:19"
]
}
}
}
],
“data”: {
“users”: null
}
}

Any feedback for us? we are somewhat stuck after researching the web. it seems we are doing everything we should be doing.

Let’s see how you entered the auth token in the playground? And you definitely ticked all the relevant permissions? :slight_smile:

Thanks Matt for reaching out - much appreacited; I took 5 screnshots that should show the login request, the query request as well as the user, role and permissions in the backend. Am I missing something?

I think that should be “Authorization” instead of “Authentication” :slight_smile:

1 Like

You are my hero! that worked. thank you!!

1 Like