amazon-web-services - React Native 中的 AWS Appsync 401 和 403 错误
问题描述
我一直在努力在我的 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 错误。有人可以指出我可以进一步调试的方向吗?
解决方案
这可能是您阅读的文档/文章中的拼写错误。尝试更换:
auth: {
type: appSyncConfig.authType,
apiKey: appSyncConfig.apiKey
}
和 :
auth: {
type: appSyncConfig.authenticationType,
apiKey: appSyncConfig.apiKey
}
推荐阅读
- python - 来自图表的微笑
- ffmpeg - 如何每隔 yy 秒剪切 xx 秒并使用 ffmpeg 在视频中循环直到结束
- java - 获取直到特定时间点的时间
- azure - IP 地址如何在 Azure vnet 中连接到 vnet 连接
- php - 一旦在任何事件发生后重新获取,就使用 ajax for table。?
- css - 数据源 mat-cell 高度和数据
- python - Python - 从导入 PostgreSQL 的 csv 文件中删除特殊字符
- c# - 如何使用 cookie 保护 asp.net 核心中间件?
- java - iBatis 语句外部化
- redis - redis哨兵故障转移后返回老主人