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.

gefragt vor 2 Jahren4153 Aufrufe
1 Antwort
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
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen