相关疑难解决方法(0)

如何从 python 向 AppSync 发送 GraphQL 查询?

我们如何使用 boto 通过 AWS AppSync 发布 GraphQL 请求?

最终,我试图模仿一个移动应用程序访问我们在 AWS 上的无堆栈/云形成堆栈,但使用 python。不是 javascript 或放大。

主要痛点是身份验证;我已经尝试了十几种不同的方法。这是当前的一个,它生成一个带有“UnauthorizedException”和“Permission denied”的“401”响应,考虑到我收到的一些其他消息,这实际上非常好。我现在使用 'aws_requests_auth' 库来完成签名部分。我假设它使用/.aws/credentials我本地环境中存储的来验证我的身份,还是这样?

我对认知身份和池将在何处以及如何进入其中感到有些困惑。例如:说我想模仿注册顺序?

无论如何,代码看起来很简单;我只是不理解身份验证。

from aws_requests_auth.boto_utils import BotoAWSRequestsAuth

APPSYNC_API_KEY = 'inAppsyncSettings'
APPSYNC_API_ENDPOINT_URL = 'https://aaaaaaaaaaaavzbke.appsync-api.ap-southeast-2.amazonaws.com/graphql'

headers = {
    'Content-Type': "application/graphql",
    'x-api-key': APPSYNC_API_KEY,
    'cache-control': "no-cache",
}
query = """{
    GetUserSettingsByEmail(email: "john@washere"){
      items {name, identity_id, invite_code}
    }
}"""


def test_stuff():
    # Use the library to generate auth headers.
    auth = BotoAWSRequestsAuth(
        aws_host='aaaaaaaaaaaavzbke.appsync-api.ap-southeast-2.amazonaws.com',
        aws_region='ap-southeast-2',
        aws_service='appsync')

    # Create an http graphql request.
    response = requests.post(
        APPSYNC_API_ENDPOINT_URL, 
        json={'query': …
Run Code Online (Sandbox Code Playgroud)

python-3.x boto3 aws-appsync

10
推荐指数
3
解决办法
4775
查看次数

标签 统计

aws-appsync ×1

boto3 ×1

python-3.x ×1