amazon-cognito - 使用 Cognito 用户池对 AppSync 查询控制台进行身份验证
问题描述
我正在尝试在 AWS AppSync 控制台中对 Queries Playground 进行身份验证。我创建了用户池并将其链接到 AppSync API,我还在 Cognito 用户池中创建了一个应用程序客户端(使用 CloudFormation 部署)。它出现Select the authorization provider to use for running queries on this page:
在控制台下方。当我运行测试查询时,我得到:
{
"errors": [
{
"errorType": "UnauthorizedException",
"message": "Unable to parse JWT token."
}
]
}
这是我所期望的。有一个选项Login with User Pools
。问题是我无法选择任何Client ID
内容,当我选择手动插入客户 ID 时,我输入的任何内容都会得到Invalid UserPoolId format
。我正在尝试从用户池常规设置(格式 eu-west-2_xxxxxxxxx)中复制池 ID,但没有任何乐趣。顺便说一句,我没有使用 Amplify,也没有配置任何身份池。
编辑:
这是 CloudFormation GraphQLApi 定义:
MyApi:
Type: AWS::AppSync::GraphQLApi
Properties:
Name: !Sub "${AWS::StackName}-api"
AuthenticationType: AMAZON_COGNITO_USER_POOLS
UserPoolConfig:
UserPoolId: !Ref UserPoolClient
AwsRegion: !Sub ${AWS::Region}
DefaultAction: ALLOW
解决方案
要使用 CloudFormation 设置堆栈,我遵循了以下 2 个示例:
https://adrianhall.github.io/cloud/2018/04/17/deploy-an-aws-appsync-graphql-api-with-cloudformation/
https://gist.github.com/adrianhall/f330a10451f05a529680f32978dddb64
事实证明,他们(同一作者)在定义 ApiGraphQL 的部分中都有问题。这个:
MyApi:
Type: AWS::AppSync::GraphQLApi
Properties:
Name: !Sub "${AWS::StackName}-api"
AuthenticationType: AMAZON_COGNITO_USER_POOLS
UserPoolConfig:
UserPoolId: !Ref UserPoolClient
AwsRegion: !Sub ${AWS::Region}
DefaultAction: ALLOW
应该:
MyApi:
Type: AWS::AppSync::GraphQLApi
Properties:
Name: !Sub "${AWS::StackName}-api"
AuthenticationType: AMAZON_COGNITO_USER_POOLS
UserPoolConfig:
UserPoolId: !Ref UserPool
AwsRegion: !Sub ${AWS::Region}
DefaultAction: ALLOW
感谢@Myz 指点我回顾整个 CF yaml 文件
推荐阅读
- .net - Azure 管道 - dotnet 发布覆盖 VSBuild .zip 然后抱怨找不到它们
- python - Python Web 应用程序 - 关于长时间请求的问题
- r - 如何将重复节点修剪到最近的共同祖先?数据树 R
- visual-studio-code - vscode 自动导入 import * as console from 'console'
- java - 将 HTTP 请求中的多个参数发送到 NetBeans 时,我的 @Path 注释有什么问题?
- flutter - Flutter:如何正确显示带有 listview.builder 的表单?
- python - 无法从 Python 3.x 以 .txt 格式保存文件
- google-maps - 以编程方式监控 Google API 使用情况?
- rabbitmq - RabbitMQ Quorum Queue - 初始领导者宕机时未找到新领导者
- python - 分组数据框的滚动操作