AWS-Cognito身份验证-卷曲调用-在没有CLI的情况下生成令牌-没有客户端机密 [英] AWS - Cognito Authentication - Curl Call - Generate Token Without CLI - No Client Secret

查看:174
本文介绍了AWS-Cognito身份验证-卷曲调用-在没有CLI的情况下生成令牌-没有客户端机密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个API网关,并在此应用了Cognito身份验证。在这里使用API​​调用来工作,我正在使用AWS CLI获取令牌,这是我的CLI代码

I have created a API Gateway and I have applied Cognito Authentication there. Here to have the API Call work I am using AWS CLI to get Token , Here is my CLI Code

aws cognito-idp admin-initiate-auth --user-pool-id us-west-2_leb660O8L --client-id 1uk3tddpmp6olkpgo32q5sd665 --auth-flow ADMIN_NO_SRP_AUTH --auth-parameters USERNAME=myusername,PASSWORD=mypassword

现在,我想使用CURL调用代替此CLI调用。我已经找到了代码,但是这里都需要客户端密码。我没有客户端机密,因为我的用户池启用了启用基于服务器的身份验证的登录。

Now I want to use CURL Call instead of this CLI Call. I have found the code but all needs client secret here. I do not have client secret as my user pool is of Enable Signin for server-based authentication.

请指导我如何使用它。

Please guide me how I can use that.

我经历了
https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminInitiateAuth.html
[什么将成为调用IntiateAuth或AdminIntiateAuth]
&
https://docs.aws.amazon。 com / cognito / latest / developerguide / token-endpoint.html

总结一下:
我想使用Curl或Postman获得Id_Token客户机密。

To Summarise this : I want to get Id_Token Using Curl or Postman without Client Secret.

预先感谢

推荐答案

您可以验证用户具有以下要求。
这是 InitiateAuth 请求。

You can authenticate a user with the following request. This is the endpoint of the InitiateAuth request.

希望这对您有用

Method: POST
Endpoint: https://cognito-idp.{REGION}.amazonaws.com/
Content-Type: application/x-amz-json-1.1
X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth
Body:
{
    "AuthParameters" : {
        "USERNAME" : "YOUR_USERNAME",
        "PASSWORD" : "YOUR_PASSWORD"
    },
    "AuthFlow" : "USER_PASSWORD_AUTH", // Don't have to change this if you are using password auth
    "ClientId" : "APP_CLIENT_ID"
}

和以下响应

{
    "AuthenticationResult": {
        "AccessToken": "YOUR_ACCESS_TOKEN",
        "ExpiresIn": 3600,
        "IdToken": "YOUR_ID_TOKEN",
        "RefreshToken": "YOUR_REFRESH_TOKEN",
        "TokenType": "Bearer"
    },
    "ChallengeParameters": {}
}

这篇关于AWS-Cognito身份验证-卷曲调用-在没有CLI的情况下生成令牌-没有客户端机密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆