0

I have deployed an GraphQL API to AWS Lambda using the Zappa Framework. If I do a request from my local machine to the local server version like this everything works fine:

import requests

url = 'http://127.0.0.1:8000/graphql'
token = '...'
headers = {'Authorization': 'JWT '+token}

query = { 'query' : '{ ...}

r = requests.get(url=url, json=query, headers=headers)
print (r.text)

If I do the same request to my AWS URL https://xyz.execute-api.eu-central-1.amazonaws.com/production/graphql it yields the following error:

<H1>403 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)

It should be noted that the GraphiQL view works properly under the mentioned AWS URL where I can do my queries without any problems. Am I missing something to get it going from other devices machine to machine?

Cheers!

Peterhack
  • 941
  • 4
  • 15
  • 34
  • 1
    I don't think this problem is related to graphql, I guess there is something wrong with the Authorization token you are passing in the header, I'm not sure JWT tokens are sent like this:`"JWT " + token` try this: `'Authorization': 'Bearer ' + token` – ganjim Oct 04 '18 at 14:45
  • 1
    The default header prefix is JWT: https://github.com/flavors/django-graphql-jwt As it works on the local machine with this config, I do not think this is the issue. – Peterhack Oct 05 '18 at 08:19
  • yes, it looks like you are right, but I don't see people answering a lot of graphql questions here, I guess because its new! and Also, please fix the query part in your code, its not complete and it can make the question unclear – ganjim Oct 05 '18 at 19:12
  • I can see your point, but the query part is the same as the one that works locally. So I assume it is about some django, zappa or aws settings? – Peterhack Oct 06 '18 at 08:15
  • It could be, I'm not that much experienced with django – ganjim Oct 06 '18 at 09:35
  • I can do a query using a local apollo graphql client, but it does not work with the presented request in python. – Peterhack Oct 10 '18 at 12:05

0 Answers0