following amazon documentation here https://docs.aws.amazon.com/sdk-for-go/v1/api/service.cognitoidentityprovider.ListUsersInput.html
I manage to follow the query creation filtering by email, it returns ListUsersInput
which I can iterate through using a for range expression. However, i want to get the value of the email attribute to make sure it is user i'm looking for (can return many users ). How do you go about that ?
I don't know if there an easy way i am missing on how to do it. I've been thinking on lopping through the attributes array and checking the name
property of each attribute but it seems like there should be an easier way.
import(
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider")
func GetUserByEmailFromCognito(userEmail string) (*cognitoidentityprovider.UserType, error){
identityProvider, _ := getCognitoClient();
emailFilter := fmt.Sprint("email=\"%s\"",userEmail)
userListInput := cognitoidentityprovider.ListUsersInput{
Filter: &emailFilter,
}
results, err := identityProvider.ListUsers(&userListInput)
if err !=nil{
return nil, err
}
for _, user := range results.Users{
//useruser.Attributes // how do i get the value of Attribute email? or phone number ?
}
}
Hopefully some one here ha already encountered this and know how to deal with it.