pmill / aws-cognito

A PHP library for AWS Cognito user pools
MIT License
74 stars 62 forks source link

Adding users when Cognito set to: Only allow administrators to create users #37

Open TonyP1961 opened 4 years ago

TonyP1961 commented 4 years ago

Hi, When Cognito is set to 'Only allow administrators to create users', and running the registerUser.php script I get this error: PHP Fatal error: Uncaught exception 'Aws\\CognitoIdentityProvider\\Exception\\CognitoIdentityProviderException' with message 'Error executing "SignUp" on "https://cognito-idp.eu-west-2.amazonaws.com"; AWS HTTP error: Client error:POST https://cognito-idp.eu-west-2.amazonaws.comresulted in a400 Bad Requestresponse:\n{"__type":"NotAuthorizedException","message":"SignUp is not permitted for this user pool"}\n NotAuthorizedException (client): SignUp is not permitted for this user pool - {"__type":"NotAuthorizedException","message":"SignUp is not permitted for this user pool"}'\n\nGuzzleHttp\\Exception\\ClientException: Client error:POST https://cognito-idp.eu-west-2.amazonaws.comresulted in a400 Bad Requestresponse:\n{"__type":"NotAuthorizedException","message":"SignUp is not permitted for this user pool"}\n in /home/ubuntu/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113\nStack trace:\n#0 /home/ubuntu/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\\Exception\\RequestException::create(Object(GuzzleHtt in /home/ubuntu/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php on line 192

When running with Allow users to sign up it works fine and user is added.

I don't want users to signup themselves, only myself, but the process is automated using this script to complete the process, as they have to be verified first as a client already in out system.

Thanks for any help on this.

pmill commented 4 years ago

Hi @TonyP1961, I'd be happy to accept a PR if you've managed to find a fix.

abhi36 commented 4 years ago

This is a feature request and should be closed soon with recent merges