question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom Auth Flow Notworking

See original GitHub issue

Describe the bug Custom Auth Flow is not working. This is the error I receive from the console. Error: Authentication flow type is invalid. at CognitoUser.authenticateUser (CognitoUser.js:220) at Auth.js:432 at new ZoneAwarePromise (zone.js:891) at AuthClass.push…/node_modules/@aws-amplify/auth/lib/Auth.js.AuthClass.signInWithPassword (Auth.js:431) at AuthClass.push…/node_modules/@aws-amplify/auth/lib/Auth.js.AuthClass.signIn (Auth.js:323) at AuthClass.aws_amplify__WEBPACK_IMPORTED_MODULE_0___default.a.Auth.signIn (auth.decorator.js:34) at CustomAuthService.push…/src/@fuse/services/custom-auth-service.ts.CustomAuthService.login (custom-auth-service.ts:45) at LoginComponent.push…/src/app/main/pages/authentication/login/login.component.ts.LoginComponent.login (login.component.ts:68) at Object.eval [as handleEvent] (LoginComponent.html:13) at handleEvent (core.js:10258) To Reproduce Steps to reproduce the behavior:

  1. go to https://github.com/koolkav1/angular-custom-auth-flow-aws/blob/sample-branch/
  2. download the branch
  3. Set up your own Cognito with Custom Auth
  4. add Mobile Hub Credentials to aws-exports.ts
  5. ng serve --open and navigate to http://localhost:4200/pages/auth/login

Expected behavior A clear and concise description of what you expected to happen.

Being able to flow through the authentication pages effectively. Flow through the authentication

Sample code Lambda functions for the custom auth flow

// defineAuthChallenge
    exports.handler = (event, context, callback) => {
        // TODO implement
        console.log("In lambda");
        //callback(null, 'Hello from Lambda');
        if(event.request.session.length === 0){
            event.response.issueTokens = false;
            event.response.failAuthentication = false;
            event.response.challengeName = 'CUSTOM_CHALLENGE'
        } else if(event.request.session.length === 1
        && event.request.session[0].challengeName === 'CUSTOM_CHALLENGE'
        && event.request.session[0].challengeResult === true){
            event.response.issueTokens = true;
            event.response.failAuthentication = false;
        } else {
            event.response.issueTokens = false;
            event.response.failAuthentication = true;
        }
        callback(null, event);
    };


    // createAuth
    console.log("Loading Function");
exports.handler = (event, context, callback) => {
    if(event.request.session.length === 0
    && event.request.challengeName === 'CUSTOM_CHALLENGE'){
        //CreateCode
        let answer = '123456';
        
        //Set the return parameters --Including correct answer
        event.response.publicChallengeParameters = {};
        event.response.privateChallengeParameters = {};
        event.response.privateChallengeParameters.answer = answer;
        event.response.challengeMetaData = 'PASSWORD_CHALLENGE';
    }
    callback(null, event);
};
//verifyAuth

exports.handler = (event, context, callback) => { 
    if(event.request.privateChallengeParameters.answer === event.request.challengeAnswer){
        event.response.answerCorrect = true;
        } else { event.response.answerCorrect = true;
                } 
                callback(null, event);
     };

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mbappaicommented, Jun 20, 2020

Hey! I am currently encountering this same issue. I keep seeing the authenticationFlowType:'CUSTOM_AUTH' whenever I log out my console, but my app someone still uses USER_SRP_AUTH which is the default flow type. Were you able to find a solution to this issue please?

0reactions
github-actions[bot]commented, Jun 20, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom authentication challenge Lambda triggers
These Lambda triggers issue and verify their own challenges as part of a user pool custom authentication flow. Define auth challenge.
Read more >
Custom auth flow is not saving the token - Retool Forum
I'm trying to set a variable name PASSWORD from my response JSON but it's always showing undefined. I've tries multiple ways to access...
Read more >
Amazon Cognito - How to fix the error "Auth flow not enabled ...
I opened the App clients from General Settings of my Cognito user pool named APIAuthPool: The problem was that I forgot to check...
Read more >
Continue with custom auth flow after ... - Stack Overflow
The client responds to the auth challenge with a new password, Cognito accepts the password and issues the tokens, which is not what...
Read more >
Cognito Custom authentication flow - getting user input mid-flow
I am creating a custom authentication flow using AWS Cognito to send a MFA code via email through the cognito ... Edit: Someone...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found