* Which Category is your question related to? *
Auth
* What AWS Services are you utilizing? *
Cognito
* Provide additional details e.g. code snippets *
I am using Amplify within Angular.
I have implemented a pre-sign up hook that declines certain users. When this hook is triggered during the federatedSignIn flow it redirects to google/facebook and then on the return the url is:
http://localhost:4200/auth-return?error_description=PreSignUp%20failed%20with%20error%cognito_presignup_custom_error.%20&state=state_code&error=invalid_request
And I have the following error message:
Unhandled Promise rejection: PreSignUp+failed+with+error+cognito_presignup_custom_error.+ ; Zone:
at OAuth.
at step (OAuth.js:52)
at Object.next (OAuth.js:33)
at OAuth.js:27
at new ZoneAwarePromise (zone-evergreen.js:876)
at push../node_modules/@aws-amplify/auth/lib/OAuth/OAuth.js.__awaiter (OAuth.js:23)
at OAuth.push../node_modules/@aws-amplify/auth/lib/OAuth/OAuth.js.OAuth.handleAuthResponse (OAuth.js:181)
at AuthClass.
at step (Auth.js:44)
at Object.next (Auth.js:25) Error: PreSignUp+failed+with+error+cognito_presignup_custom_error.+
at OAuth.
at step (http://localhost:4200/vendor.js:111098:23)
at Object.next (http://localhost:4200/vendor.js:111079:53)
at http://localhost:4200/vendor.js:111073:71
at new ZoneAwarePromise (http://localhost:4200/polyfills.js:3920:29)
at push../node_modules/@aws-amplify/auth/lib/OAuth/OAuth.js.__awaiter (http://localhost:4200/vendor.js:111069:12)
at OAuth.push../node_modules/@aws-amplify/auth/lib/OAuth/OAuth.js.OAuth.handleAuthResponse (http://localhost:4200/vendor.js:111227:16)
at AuthClass.
at step (http://localhost:4200/vendor.js:109222:23)
at Object.next (http://localhost:4200/vendor.js:109203:53)
Any thoughts on how I can catch this error?
I'm having the exact same problem in React.
Same problem in angular. I've tried lots of different configurations and still not able to make it work.
Wow, no answers? :(
Apparently you can catch the error with Hub.listen, but you have to register the callback before the Auth module processes the result from the redirect. Calling Hub.listen before Amplify.configure and logging the payload I got this in the console:
{
"event":"parsingCallbackUrl",
"data":{
"url":"http://localhost:19006/dash/?error_description=PreSignUp+failed+with+error+LINKED_EXTERNAL_USER%3A+Google.+&state=KustOP4fqhIPA9ckz226D9Qk7Wt27zr5&error=invalid_request"
},
"message":"The callback url is being parsed"
}
[ERROR] 19:26.131 OAuth - Error handling auth response. Error: PreSignUp+failed+with+error+LINKED_EXTERNAL_USER%3A+Google.+
at OAuth.<anonymous> (OAuth.js:236)
at step (OAuth.js:55)
at Object.next (OAuth.js:36)
at OAuth.js:30
...
{
"event":"configured",
"data": null,
"message":"The Auth category has been configured successfully"
}
{
"event":"signIn_failure",
"data":{ // Error object
message: "PreSignUp+failed+with+error+LINKED_EXTERNAL_USER%3A+Google.+",
stack: "Error: PreSignUp+failed+with+error+LINKED_EXTERNAL_USER%3A+Google..."
},
"message":"The OAuth response flow failed"
}
{
"event":"cognitoHostedUI_failure",
"data":{ // Error object
message: "PreSignUp+failed+with+error+LINKED_EXTERNAL_USER%3A+Google.+",
stack: "Error: PreSignUp+failed+with+error+LINKED_EXTERNAL_USER%3A+Google..."
},
"message":"A failure occurred when returning to the Cognito Hosted UI"
}
{
"event":"customState_failure",
"data":{ // Error object
message: "PreSignUp+failed+with+error+LINKED_EXTERNAL_USER%3A+Google.+",
stack: "Error: PreSignUp+failed+with+error+LINKED_EXTERNAL_USER%3A+Google..."
},
"message":"A failure occurred when returning state"
}
Most helpful comment
Same problem in angular. I've tried lots of different configurations and still not able to make it work.