1 Answer
- Newest
- Most votes
- Most comments
0
This error implies that you have a different authorization method enabled on AppSync than "AWS Identity and Access Management (IAM)". The default authorization method is "API key".
Changing the authorization method:
- Navigate to the AppSync resource in the AWS Console
- Click on the Settings option in the left-hand menu
- Select default authorization mode as shown below
Using API Key Sample
To change your python code to use API key, please refer to the below sample
import requests
session = requests.Session()
session.headers = {'x-api-key': '<INSERTAPIKEYHERE'}
# As found in AWS Appsync under Settings for your endpoint.
APPSYNC_API_ENDPOINT_URL = APPSYNC_ENDPOINT
# Use JSON format string for the query. It does not need reformatting.
query = """query MyQuery {
getCustomer(id: "38c76f4f-c495-42e6-8599-647738a12692") {
first_name
}
}"""
# Now we can simply post the request...
response = session.request(
url=APPSYNC_API_ENDPOINT_URL,
method='POST',
json={'query': query}
)
print(response.text)
answered 9 months ago
Relevant content
- Accepted Answerasked 6 months ago
- asked 2 years ago
- asked 5 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago