【发布时间】:2022-04-24 20:19:13
【问题描述】:
当我在我的项目中实施 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
我用的是这个网址: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;
【问题讨论】:
标签: php amazon-web-services amazon-cognito