【问题标题】:AWS Cognito NotAuthorizedException A client attempted to write unauthorized attributeAWS Cognito NotAuthorizedException 客户端试图写入未经授权的属性
【发布时间】:2017-07-06 13:37:58
【问题描述】:

我将 AWS Cognitoaws-cpp-sdk 用于我的应用程序。我定义了一个用户池和一个应用程序,然后我得到了应用程序客户端 ID 和应用程序密码。 我可以创建用户池对象:

    Aws::Client::ClientConfiguration clientConfig;
    clientConfig.region =
        Aws::Region::EU_CENTRAL_1;  // "RegionEndpoint.EUCentral1";
    clientConfig.scheme = Aws::Http::Scheme::HTTPS;
    clientConfig.connectTimeoutMs = 30000;
    clientConfig.requestTimeoutMs = 600000;

    CognitoIdentityProviderClient client;
    client = CognitoIdentityProviderClient(clientConfig);

    DescribeUserPoolClientRequest describeUserPoolClientRequest;
    describeUserPoolClientRequest.WithUserPoolId(POOL_ID)
        .WithClientId(TEST_APP_CLIENT_ID);
    DescribeUserPoolClientOutcome describeUserPoolClientOutcome =
        client.DescribeUserPoolClient(describeUserPoolClientRequest);

我用SignUpRequest定义了一个用户后,出现了这样的错误:NotAuthorizedException A client试图写未经授权的属性

这是我的注册码:

    SignUpRequest signUpRequest;
    signUpRequest.SetClientId(describeUserPoolClientOutcome.GetResult()
                                  .GetUserPoolClient()
                                  .GetClientId());
    signUpRequest.SetUsername("xxxxx");
    signUpRequest.SetPassword("xxxxxx?");
    AttributeType email, phone_number, gender, given_name, family_name, picture;
    email.WithName("email").WithValue("gacer@ku.edu.tr");
    phone_number.WithName("phone_number").WithValue("+xxxxx");
    given_name.WithName("given_name").WithValue("xxx");
    family_name.WithName("familiy_name").WithValue("xxx");
    gender.WithName("gender").WithValue("MALE");
    picture.WithName("picture").WithValue(
        "http://xxxx");
    signUpRequest.AddUserAttributes(email);
    signUpRequest.AddUserAttributes(phone_number);
    signUpRequest.AddUserAttributes(given_name);
    signUpRequest.AddUserAttributes(family_name);
    signUpRequest.AddUserAttributes(gender);
    signUpRequest.AddUserAttributes(picture);

    SignUpOutcome signUpOutcome = client.SignUp(signUpRequest);

有什么问题?我该如何解决?

【问题讨论】:

    标签: amazon-web-services aws-sdk aws-cognito


    【解决方案1】:

    在 AWS 网站中,转到您的用户池 -> 应用程序 -> 显示详细信息 -> 设置属性读写权限。确保您尝试在可写属性列表中写入 i 的每个属性都带有复选标记。

    【讨论】:

    • 感谢您的回复。我应用了它,但问题仍然存在。
    【解决方案2】:

    我有同样的问题,但通过在其他属性中添加 custom: 解决了。 在添加自定义属性时 你需要添加

    custom:family_name

    【讨论】:

      【解决方案3】:

      天哪!异常的原因只是书写错误。通过在此行更正从家庭到家庭的打字错误,问题得到解决:

      family_name.WithName("familiy_name").WithValue("xxx");
      

      【讨论】:

        猜你喜欢
        • 2017-10-16
        • 2019-04-27
        • 2019-10-15
        • 2018-12-18
        • 2020-06-04
        • 2019-12-12
        • 2020-01-11
        • 2013-08-03
        • 2015-02-01
        相关资源
        最近更新 更多