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.

preguntada hace 2 años4153 visualizaciones
1 Respuesta
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
respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas