PHP AWS Cognito'执行“ SignUp”时出错:ResourceNotFoundException:用户池客户端XXXX不存在

时间:2018-10-25 09:59:21

标签: php amazon-web-services amazon-cognito

当我在项目中实现AWS Cognito时,发生以下错误。

Uncaught exception 'Aws\CognitoIdentityProvider\Exception\CognitoIdentityProviderException' with message 'Error executing "SignUp" on "https://cognito-idp.us-east-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://cognito-idp.us-east-1.amazonaws.com` resulted in a `400 Bad Request` response: {"__type":"ResourceNotFoundException","message":"User pool client XXXX does not exist."} ResourceNotFoundException (client): User pool client XXXX does not exist. - {"__type":"ResourceNotFoundException","message":"User pool client XXXX does not exist."}' GuzzleHttp\Exception\ClientException: Client error: `POST https://cognito-idp.us-east-1.amazonaws.com` resulted in a `400 Bad Request` response: {"__type":"ResourceNotFoundException","message":"User pool client XXXX does not exist."} in /vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php on line 191

我曾使用过以下URL:https://github.com/pmill/aws-cognito

这是我的PHP代码:

if(isset($_POST['action'])) {
    $username = $_POST['username'] ?? '';
    $password = $_POST['password'] ?? '';

    if($_POST['action'] === 'register') {
        $email = $_POST['email'] ?? '';

        $error = $client->registerUser($username, $password, [
            'email' => $email,
        ]);

        if(empty($error)) {
            header('Location: confirm.php?username=' . $username);
            exit();
        }
    }}

这是config.php文件。

$config = [
'credentials' => [
    'key' => 'XXXXXXXXXXXXXXXX',
    'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
],
'region' => 'XXXXXXXXXXXXXXXX',
'version' => 'latest',
'app_client_id' => 'XXXXXXXXXXXXXXXX',
'app_client_secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'user_pool_id' => 'XXXXXXXXXXXXXXXX'];

require './vendor/autoload.php';

$aws = new \Aws\Sdk($config);
$cognitoClient = $aws->createCognitoIdentityProvider();
$client = new \pmill\AwsCognito\CognitoClient($cognitoClient);
$client->setAppClientId($config['app_client_id']);
$client->setAppClientSecret($config['app_client_secret']);
$client->setRegion($config['region']);
$client->setUserPoolId($config['user_pool_id']);
return $client;

1 个答案:

答案 0 :(得分:-1)

如果您要传递的客户端ID实际上不存在,则会引发错误。 可能是在其他区域中创建了用户池,或者配置参数错误