[Vuejs]-Vue.js: "onSuccess" and "onFailure" callbacks not working

0👍

After some debugging, I found the onSuccess callback worked when I changed RedirectUriSignIn in authData as follows:

var authData = {
   ClientId : appclient_id, // Your client id here
   AppWebDomain : 'my-sample-app.amazoncognito.com',
   TokenScopesArray : ['email'], 
   RedirectUriSignIn : 'http://localhost:8080/signup',  <------- here
   RedirectUriSignOut : 'http://localhost:8080',
   IdentityProvider : 'Facebook', // e.g. 'Facebook',
   UserPoolId : cognitoUserPoolId, // Your user pool id here
};

This will redirect to the component where amazon-cognito-auth-js is initialized.

In my case, I was redirecting it to the ‘/’ (Home.vue), which didn’t have amazon-cognito-auth-js initialized, everything was initialized in ‘/signup’ (SignUp.vue) so it makes sense to redirect to the ‘/signup’ route.

Make sure to change the redirect_url as well, in AWS Cognito App client settings:

AWS Console --> Cognito --> Userpools --> App client settings --> Sign in and sign out URLs --> Callback URL(s)

Change Callback URL(s) to:

http://localhost:8080/signup

Leave a comment