donglun2024 2019-08-21 09:09
浏览 312
已采纳

当用户已经确认时,Cognito抛出ErrCodeNotAuthorizedException

Why does cognito throw ErrCodeNotAuthorizedException "NotAuthorizedException" when the status of the user is already confirmed when making a request to cognito to confirm the user. The documentation specifies that ErrCodeNotAuthorizedException is thrown when a user is not authorized.

https://docs.aws.amazon.com/sdk-for-go/api/service/cognitoidentityprovider/#CognitoIdentityProvider.ConfirmSignUp

How should we handle this case? As it would be unclear if we made a request with invalid client secret as it would throw the same error.

  • 写回答

1条回答 默认 最新

  • douzhuang2570 2019-08-22 04:57
    关注

    Since the code is the same for the unauthorized case and user already confirmed case, the only possible way to differentiate the cases is to match the awsErr.Message() which provides the clear description of the error.

    if awsErr, ok := err.(awserr.Error); ok {
        switch awsErr.Code() {
          case cognitoidentityprovider.ErrCodeNotAuthorizedException:
            if awsErr.Message() == "User cannot be confirm. Current status is CONFIRMED" {
                log.Println("Handle user already confirmed")
            } else {
                log.Println("Handle not authorized case")
            }
          ...
          default:          
        }
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)