How do I authenticate using GraphiQL?
  • 28 Jun 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light

How do I authenticate using GraphiQL?

  • Dark
    Light

Article Summary

How do I authenticate when using the web interface GraphiQL?

Request an authentication token with cURl and use the GraphiQL interface to send requests.

Installing ModHeader

When using GraphiQL you have to include an authentication token in the header. You can use the extension ModHeader for this. You can find the links to the stores for the different browsers here: ModHeader

Request token via cURL

Add Client ID and Client Secret here and request a token:

curl --request POST \
  --url https://promaterial.eu.auth0.com/oauth/token \
  --header 'content-type: application/json' \
  --data '{
      "client_id":"<your client ID>",
      "client_secret":"<your client secret>",
      "audience": "http://mdg.promaterial.com/api",
      "grant_type": "client_credentials"
      }'

You will receive the following response:

{
  "access_token":"<access token, valid for 24 hours>",
  "scope": "read:products read:order read:shoppingCart",
  "expires_in": 86400,
  "token_type": "bearer"
}

Using GraphiQL

Access the GraphiQL interface from this link:

http://<your-dg-code>.dg.prod.promaterial.com/api

Open the "ModHeader" extension and add the "Authorization" header. The value is "Bearer " and the "access_token" from the response of the previous request.


Was this article helpful?