首页 > 解决方案 > 在 AWS Cognito 中设置自定义属性

问题描述

我在 aws cognito 中使用 google 作为联合身份。

我已经创建了用户,但我无法添加自定义属性,我在用户池中有。我正在尝试使用控制台添加自定义属性。

User and Groups当我点击-> Any of the user时,我没有看到这个自定义属性。

我还尝试使用 cognito 池作为 Idp(以及 Google),但这也没有改变任何东西。

我也尝试过使用这个创建用户:

aws cognito-idp admin-create-user \
    --profile stage \
    --region ap-south-1 \
    --user-pool-id SSO-Test-User-Pool \
    --username test@test.com \
    --user-attributes Name=email,Value=test@test.com Name=custom:custom:role,Value="cms.tv_admin" \
    --message-action SUPPRESS

但它给出了错误:

An error occurred (InvalidParameterException) when calling the AdminCreateUser operation: 1 validation error detected: Value 'SSO-Test-User-Pool' at 'userPoolId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w-]+_[0-9a-zA-Z]+

当我尝试使用此更新属性时也是如此:

aws cognito-idp admin-update-user-attributes \
    --profile stage \
    --region ap-south-1 \
    --user-pool-id SSO-Test-User-Pool \
    --username Google_113423776936123400493 \
    --user-attributes Name=custom:custom:role,Value=admin

此外,我发现这些命令可以使用该应用程序运行,并且他们需要在登录后返回代码,我想他们将使用重定向 URI 获得这些代码。

如何从 CLI 使用它?

我在App Client Settings.

谢谢。

如果需要更多信息,请告诉我。

自定义属性

用户属性页

应用客户端设置

应用程序客户端设置 - 可读/可写权限

标签: amazon-web-servicesamazon-cognito

解决方案


这是您的联合池名称,而不是联合池 ID。

您可以通过以下方法获取联合池 ID:

从控制台选择您的身份池,在上面页面的顶部Pool ARN将是Pool Id. 它将以创建池的区域为前缀。

或者运行list-identity-pools,然后从Id属性中复制值。


推荐阅读