Когда я внедряю 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;