用户在使用AWS Cognito的电子邮件登录选项时,可以更改电子邮件吗?

huangapple go评论73阅读模式
英文:

Can users change email when using the email login option on AWS Cognito

问题

我正在使用AWS Cognito,并想知道如何在Golang中使用AdminUpdateUserAttributes来更改电子邮件地址。

在cognito设置过程中,在cognito用户池创建中的“您希望用户如何登录”标题下,我选择了通过电子邮件登录。

这篇帖子https://stackoverflow.com/questions/66544422/can-change-the-users-email-in-aws-cognito-user-pool 对于使用用户名选项有一个答案。

英文:

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 https://stackoverflow.com/questions/66544422/can-change-the-users-email-in-aws-cognito-user-pool has an answer for when using the username option.

答案1

得分: 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),
})

在你的情况下,aws.String(email) 应该可以工作。

或者

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

英文:
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),
			},
		},
})

huangapple
  • 本文由 发表于 2022年7月28日 10:06:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/73146446.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定