Amazon web services 提供身份验证代码时接收到来自AWS Cognito的无效授权类型错误:如何获取用于测试的Id和访问令牌?

Amazon web services 提供身份验证代码时接收到来自AWS Cognito的无效授权类型错误:如何获取用于测试的Id和访问令牌?,amazon-web-services,amazon-cognito,Amazon Web Services,Amazon Cognito,当我提供身份验证代码时,我无法从AWS cognito用户池成功获取id令牌/访问令牌。我已经编写了一个shell脚本(见下文),并从服务器接收到无效的\u grant 我已将python生成的client\u id:client\u secret的base64授权基本头编码为: 导入base64 encode='my\u client\u id\u string:my\u client\u secret\u string' base64.b64编码(encode) #/副秘书长/垃圾箱/环境

当我提供身份验证代码时,我无法从AWS cognito用户池成功获取id令牌/访问令牌。我已经编写了一个shell脚本(见下文),并从服务器接收到
无效的\u grant

我已将python生成的
client\u id:client\u secret
的base64授权基本头编码为:

导入base64
encode='my\u client\u id\u string:my\u client\u secret\u string'
base64.b64编码(encode)
#/副秘书长/垃圾箱/环境卫生
curl--location--request POST'https://.auth.us-east-2.amazoncognito.com/oauth2/token' \
--标题“内容类型:应用程序/x-www-form-urlencoded”\
--标题“授权:基本”\
--数据urlencode“授权类型=授权代码”\
--数据urlencode'客户端id=解决了它

问题是由无效的客户端id引起的。我为客户端id值提供了一个输入错误

#!/usr/bin/env sh

curl --location --request POST 'https://<domain>.auth.us-east-2.amazoncognito.com/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic <base64 encode string client_id:client_secret>' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'client_id=<client_id from app settings' \
--data-urlencode 'code=<code received from redirect url to my localhost app endpoint>' \
--data-urlencode 'redirect_uri=http://localhost:8000/my_redirect'