【问题标题】:User pool client {id}does not exist用户池客户端 {id} 不存在
【发布时间】:2021-04-18 09:12:42
【问题描述】:

这是我的代码:

 use Aws\CognitoIdentityProvider\CognitoIdentityProviderClient;

$args = [ 
    'credentials' => [
        'key'    => 'valid',
        'secret' => 'valid',
    ],
    'region' => 'us-west-2',
    'version' => 'latest',

    'app_client_id' => 'valid',
    'app_client_secret' => 'valid',
    'user_pool_id' => 'valid',
];

$email = 'test32@test.com';

$client = new CognitoIdentityProviderClient($args);
$hash_key = cognitoSecretHash($email);

$login =  $client->adminInitiateAuth([
            'AuthFlow' => 'ADMIN_NO_SRP_AUTH',
            'AuthParameters' => [
                'Username' => $email,
                'Password' => '12345678',
                'SecretHash' => $hash_key,
            ],
            'ClientId' => 'valid',
            'UserPoolId' => 'valid',
        ]);

return $login;


 function cognitoSecretHash($username)
{
    $message = $username . 'app_client_id';

    $hash = hash_hmac(
        'sha256',
        $message,
        'app_client_secret',
        true
    );

    return base64_encode($hash);
}

它给了我这个错误:

致命错误:未捕获异常 'Aws\CognitoIdentityProvider\Exception\CognitoIdentityProviderException' 并带有消息“在“https://cognito-idp.us-west-2.amazonaws.com”上执行“AdminInitiateAuth”时出错; AWS HTTP 错误:客户端错误:POST https://cognito-idp.us-west-2.amazonaws.com 导致 400 Bad Request 响应:{"__type":"ResourceNotFoundException","message":"用户池客户端 {id} 不存在。"} ResourceNotFoundException(客户端):用户池客户端 {id} 不存在。 - {"__type":"ResourceNotFoundException","message":"用户池客户端 {id} 不存在。"}' GuzzleHttp\Exception\ClientException: 客户端错误:POST https://cognito-idp.us-west-2.amazonaws.com 导致 400 Bad Request 响应:{" __type":"ResourceNotFoundException","message":"用户池客户端 {id} 不存在。"} 在 D:\xampp\htdocs\test\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113 堆栈跟踪:#0 D:\xampp\htdocs\test\vend 在 D:\xampp\htdocs\test\vendor\aws\aws-sdk-php\src\WrappedHttpHandler.php 第 195 行

【问题讨论】:

    标签: php amazon-cognito aws-php-sdk


    【解决方案1】:
     $login =  $client->adminInitiateAuth([
                'AuthFlow' => 'ADMIN_NO_SRP_AUTH',
                'AuthParameters' => [
                    'USERNAME' => $email,
                    'PASSWORD' => $password,
                    'SECRET_HASH' => $hash_key,
                ],
                'ClientId' => $clientId,
                'UserPoolId' => $poolId,
            ]);
    

    【讨论】:

      猜你喜欢
      • 2022-07-28
      • 1970-01-01
      • 2017-06-25
      • 2018-12-07
      • 1970-01-01
      • 2018-04-25
      • 1970-01-01
      • 2017-05-07
      • 2015-12-05
      相关资源
      最近更新 更多