Setting custom attributes in AWS Cognito

Viewed 2370

I am using google as federated identity in aws cognito.

I have got the user created but I am not able to add the custom attributes, I have in the user pool. I am trying to add custom attributes using the console.

I don't see this custom attribute when I click on User and Groups -> Any of the user.

I also tried using the cognito pool as Idp ( alongwith Google ) but that also didn't change anything.

I have also tried creating user using this :

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

But it gives error :

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]+

and same goes while I tried updating attributes using this :

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

Further I found that these commands can be run using the app and that they need to have the code returned after logging in, which they would get using the redirect URI, I suppose.

How do I use that from the CLI ?

I have the readable and writable attributes set on the custom property by the app in the App Client Settings.

Thanks.

Let me know if more info is required.

custom attribute

User Property Page

app client settings

app client settings - readable/writable permissions

1 Answers

This is your federated pool name, not the federated pool id.

You can get your federated pool id via the following methods:

From the console select your identity pool, at the top of the page above Pool ARN will be Pool Id. It will be prefixed with the region in which the pool is created.

Alternatively run the list-identity-pools, then copy the value from the Id attribute.

Related