我正在 Go 中編寫一個 Lambda 函數(shù)來對用戶進(jìn)行身份驗證,這是我想用于后續(xù) API 調(diào)用的 AccessToken/IdToken。當(dāng)我從一個獨立程序執(zhí)行 Go 代碼時,它起作用了,InitiateAuth 成功了。當(dāng)我嘗試使用來自 lambda 函數(shù)的相同代碼時,出現(xiàn)錯誤 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}我已經(jīng)為 lambda 用戶提供了足夠的權(quán)限 - cognito-idp:AdminCreateUser - cognito-idp:AdminDeleteUser - cognito-idp:InitiateAuth - cognito-idp:ChangePassword - cognito-idp:AdminRespondToAuthChallenge - cognito-idp:AdminInitiateAuth - cognito-idp:確認(rèn)忘記密碼我在這里錯過了什么嗎?
1 回答

達(dá)令說
TA貢獻(xiàn)1821條經(jīng)驗 獲得超6個贊
當(dāng)我們創(chuàng)建一個新的 App 客戶端時,默認(rèn)情況下它有一個關(guān)聯(lián)的 App 客戶端密碼。
我又創(chuàng)建了一個沒有“Client Secret”的應(yīng)用程序客戶端。我使用了這個新的 App 客戶端。
我修改了代碼以使用 API AdminInitiateAuth,而不是 InitiateAuth
我能夠成功登錄。
- 1 回答
- 0 關(guān)注
- 159 瀏覽
添加回答
舉報
0/150
提交
取消