AWS Amplify graphql客户端IAM设置

时间:2019-12-03 03:28:04

标签: amazon-web-services graphql amazon-iam aws-amplify aws-appsync

我在项目中使用Amplify graphql client。自定义身份验证后,我将获得访问密钥ID和秘密访问密钥。 我需要将这些提供给Amplify配置,但找不到任何文档。我看过的最接近的文档是:

const myAppConfig = {
    // ...
    'aws_appsync_graphqlEndpoint': 'https://xxxxxx.appsync-api.us-east-1.amazonaws.com/graphql',
    'aws_appsync_region': 'us-east-1',
    'aws_appsync_authenticationType': 'AWS_IAM',
    // ...
}

Amplify.configure(myAppConfig);

但是它没有指定凭据输入的位置。 它们是为AWS Appsync SDK指定的,但没有为graphql客户端指定的。

我们非常感谢您的协助或见解。 谢谢

1 个答案:

答案 0 :(得分:0)

我通过使用AWS.config解决了它

import AWS from "aws-sdk";

AWS.config.credentials = new AWS.Credentials(your credentials here)

Amplify.configure然后工作正常