Greetings. I'm using AWS Cognito with Federeted Identities. I have a local users table which contains email address and user privileges to my application. I'm trying to have a functionality in the admin panel to signup a user to AWS Cognito user pool. I'm using AWS PHP SDK and here's my code:
$post = $this->request->post('entity');
$client = new CognitoIdentityProviderClient([
'version' => 'latest',
'region' => 'eu-central-1',
'credentials' => [
'key' => '[KEY]',
'secret' => '[SECRET]'
]]);
try {
$result = $client->signUp([
'ClientId' => '[CLIENT_ID]',
'Username' => $post['username'],
'Password' => $post['password'],
'UserAttributes' => [
[
'Name' => 'name',
'Value' => $post['username']
],
[
'Name' => 'email',
'Value' => $user->email
]],
]);
print_r($result);
}
catch (Exception $e) {}
This generates following error message:
Error executing "SignUp" on "https://cognito-idp.eu-central-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://cognito-idp.eu-central-1.amazonaws.com` resulted in a `400 Bad Request` response: {"__type":"NotAuthorizedException","message":"Client 1qljhu6osuq9qhelblds40hhqe is configured for secret but secret was (truncated...)
Please help.