2

I am trying to set a password for a Cognito user that I have already created using the AdminSetUserPassword function, but I keep getting "Operation not found: AdminSetUserPassword" as response.

I have checked the version of CognitoIdentityProvider ('2016-04-18'), which doesn't seem to be the problem. I have also tried to go around it using AdminInitiateAuth and AdminRespondToAuthChallenge, but the problem with the InitiateAuth function is that I get no 'Session' in response! Any help would be greatly appreciated!

                    $args = [
                        'credentials' => *CREDENTIALS*,
                        'region' => 'eu-central-1',
                        'version' => 'latest',
                        'app_client_id' => *CLIENT_ID*,
                        'user_pool_id' => *USER_POOL_ID*,
                      ];

                      $client = new CognitoIdentityProviderClient($args);

                      try {

                        $response = $client->adminSetUserPassword([
                          "Password" => $new_password,
                          "Permanent" => true,
                          "Username" => *USER_USERNAME*,
                          "UserPoolId" => *USER_POOL_ID*
                        ]);
                        return true;

                      } catch (Exception $e) {
                        return false;
                      } 
S.P.S.
  • 33
  • 4

1 Answers1

0

AdminSetUserPassword was only added to the aws/aws-sdk-php package in version 3.93.3. You can update your version of the package with composer require aws/aws-sdk-php:">3.93.3".

D Malan
  • 10,272
  • 3
  • 25
  • 50
  • 1
    Thank you! It's working just fine after the update! – S.P.S. Aug 15 '19 at 08:45
  • No problem @S.P.S. ! You can mark the answer as [accepted](https://stackoverflow.com/help/someone-answers) if it answered your question. :) – D Malan Aug 15 '19 at 09:01