Client XYZ is configured for secret but secret was not received

0

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.

asked 2 years ago4085 views
1 Answer
0

For your $client, in addition to the "Client ID" you need to also include the "Client Secret" from your App Client if it is configured with one.

profile pictureAWS
Mike_P
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions