1

I am using AWS Cognito and want to know how to use AdminUpdateUserAttributes in Golang to change the email address.

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

During cognito setup, under "How do you want your users to sign in" header in cognito user pool creation I choose by email.

This post Can change the user's email in aws cognito user pool? has an answer for when using the username option.

BAR
  • 15,909
  • 27
  • 97
  • 185

1 Answers1

1
output, err := cognitoClient.IDP.AdminUpdateUserAttributes(&cognitoidentityprovider.AdminUpdateUserAttributesInput{
    Username: aws.String(username),
    UserAttributes: []*cognitoidentityprovider.AttributeType{
        {
            Name:  aws.String("email"),
            Value: aws.String(username),
        },
    },
    UserPoolId: aws.String(cognitoClient.UserPoolID),
})

In your case aws.String(email) should work.

or

output, err := cognitoClient.IDP.UpdateUserAttributes(&cognitoidentityprovider.UpdateUserAttributesInput{
        AccessToken: aws.String(accessToken),
        UserAttributes: []*cognitoidentityprovider.AttributeType{
            {
                Name:  aws.String("email"),
                Value: aws.String(username),
            },
        },
})
oldBear
  • 157
  • 2
  • 10