1

I am building an ecommerce website using strapi, apollo, graphql, nextjs, when an authenticated users ordering they need to send jwt token using headers but I am little confused how to do that. Here is my code on apollographql playground.

mutation Mutation($data: OrderInput!) {

createOrder(data: $data) { data { id attributes { name phone products { data { id attributes { price name media { data { attributes { url } } } } } } status details createdAt user { data { attributes { username } } } } } } }enter image description here enter image description here

When I do that it is giving following error.

{

"errors": [ { "message": "Forbidden access", "extensions": { "error": { "name": "ForbiddenError", "message": "Forbidden access", "details": {} }, "code": "FORBIDDEN" } }, { "message": "Forbidden access", "extensions": { "error": { "name": "ForbiddenError", "message": "Forbidden access", "details": {} }, "code": "FORBIDDEN" } } ],

Without authorisation its working fine, but I do not know how to insert jwt token

its my order content type, has relation with user

1

2 Answers 2

1

Looks fine to me. You probably inserted an expired token. Have you tried turning on the create permission for authenticated role?

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I set all the necessary permissions, and tryed using new token, but no luck. I added an image of my content type you can see on above
0

Finally I solved the issue by allowing "find" method in user permission tab.enter image description here

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.