Search code examples
authenticationgraphqlrequest-headersgraphiql

How to authenticate through Graphiql playground


It's my first time using GraphQL and I'm trying to access the content of a given query but I can't access this given query because of lack of permissions, in this case I have been given a username and a password to access this GraphQL API, and I'm able to get and verify the token using these credentials in GraphQL but my question is the following, how do I become authenticated in the API to be able to access the queries of the API?

My error is as follows.

"errors": [
    {
      "message": "You do not have permission to perform this action",

I believe this is something very basic, but I just not able to find a way to solve this issue.


Solution

  • Click HTTP Header and add your token as shown below:

    {
      "Authorization": "Bearer YOUR_TOKEN_HERE"
    }
    

    you may have to remove Bearer and only use the token, it depends on how you did authorization on the server.