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.

posta 2 anni fa4153 visualizzazioni
1 Risposta
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
con risposta 2 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande