亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

AWS Cognito InitiateAuth 通過 Lambda 函數導致錯誤

AWS Cognito InitiateAuth 通過 Lambda 函數導致錯誤

Go
動漫人物 2023-06-12 15:50:32
我正在 Go 中編寫一個 Lambda 函數來對用戶進行身份驗證,這是我想用于后續 API 調用的 AccessToken/IdToken。當我從一個獨立程序執行 Go 代碼時,它起作用了,InitiateAuth 成功了。當我嘗試使用來自 lambda 函數的相同代碼時,出現錯誤 NotAuthorizedException: Unable to verify secret hash for client ......這是我正在使用的代碼片段func AuthenticateUser(userName string, passWord string) (*cognitoidentityprovider.InitiateAuthOutput, error) {    username := aws.String(userName)    password := aws.String(passWord)    clientID := aws.String(constants.COGNITO_APP_CLIENT_ID)    params := &cognitoidentityprovider.InitiateAuthInput{        AuthFlow: aws.String("USER_PASSWORD_AUTH"),        AuthParameters: map[string]*string{            "USERNAME": username,            "PASSWORD": password,        },        ClientId: clientID,    }    authResponse, authError := cognitoClient.InitiateAuth(params)    if authError != nil {        fmt.Println("Error = ", authError)        return nil, authError    }    fmt.Println(authResponse)    fmt.Println(*authResponse.Session)    return authResponse, nil}我已經為 lambda 用戶提供了足夠的權限 - cognito-idp:AdminCreateUser - cognito-idp:AdminDeleteUser - cognito-idp:InitiateAuth - cognito-idp:ChangePassword - cognito-idp:AdminRespondToAuthChallenge - cognito-idp:AdminInitiateAuth - cognito-idp:確認忘記密碼我在這里錯過了什么嗎?
查看完整描述

1 回答

?
達令說

TA貢獻1821條經驗 獲得超6個贊

當我們創建一個新的 App 客戶端時,默認情況下它有一個關聯的 App 客戶端密碼。

我又創建了一個沒有“Client Secret”的應用程序客戶端。我使用了這個新的 App 客戶端。

我修改了代碼以使用 API AdminInitiateAuth,而不是 InitiateAuth

我能夠成功登錄。


查看完整回答
反對 回復 2023-06-12
  • 1 回答
  • 0 關注
  • 161 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號