【发布时间】:2018-12-09 15:30:16
【问题描述】:
我一直在努力在我的 React Native 应用程序中设置 Appsync 和 Cognito。
我尝试了以下两种方法:
Amplify.configure(config);
OR
Amplify.configure({
Auth: {
region: config.aws_cognito_region, // REQUIRED - Amazon Cognito Region
userPoolId: config.aws_user_pools_id, // OPTIONAL - Amazon Cognito User Pool ID
userPoolWebClientId: config.aws_user_pools_web_client_id, // User Pool App Client ID
},
});
与
const client = new AWSAppSyncClient({
url: appSyncConfig.graphqlEndpoint,
region: appSyncConfig.region,
auth: {
type: appSyncConfig.authType,
jwtToken: async () => (await Auth.currentSession()).getIdToken().getJwtToken(),
},
});
OR
const client = new AWSAppSyncClient({
url: appSyncConfig.graphqlEndpoint,
region: appSyncConfig.region,
auth: {
type: appSyncConfig.authType,
apiKey: appSyncConfig.apiKey,
},
});
我也跟着这两个教程Tackling user auth,Building a notes app。
在这两种情况下,我都在 GraphQL 中收到以下错误,没有描述:
Error: Network error: Response not successful: Received status code
这是在授权类型为Amazon Cognito User Pool 时。我也试过AWS Identity and Access Management (IAM),但这给了我一个403错误。有人可以指出我可以进一步调试的方向吗?
【问题讨论】:
标签: amazon-web-services react-native amazon-cognito amazon-iam aws-appsync