drui0508 2019-08-06 22:17
浏览 37

Go中的Cognito身份提供者:如何从Attributes数组中获取信息

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?