UserPoolIdentityProviderGoogle email_verified AttributeMapping missing in CDK construct

83 Views Asked by At

When adding Google as IDP in Cognito via Console in Mapping attribute there is an option to add email_verified attribute that will set email as Verified in your Cognito UserPool when you sign in.

But this attribute is missing in UserPoolIdentityProviderGoogle CDK construct.

The question is - does anyone know how to create custom attribute that will be possible to map as we are able to do via Console?

As you can see in the AttributeMapping list this option does not exist.

1

There are 1 best solutions below

0
On

Here's an example:

from aws_cdk import aws_cognito as cognito

attribute_mapping = cognito.AttributeMapping(
    email=cognito.ProviderAttribute.GOOGLE_EMAIL,
    family_name=cognito.ProviderAttribute.GOOGLE_FAMILY_NAME,
    given_name=cognito.ProviderAttribute.GOOGLE_GIVEN_NAME,
    custom={
        "email_verified": cognito.ProviderAttribute.other("email_verified")
    }
)

user_pool = cognito.UserPool(self, "UserPool", ...)

cognito_user_pool_google_identity_provider = cognito.UserPoolIdentityProviderGoogle(
    self,
    "CognitoUserPoolIdentityProviderGoogle",
    client_id="google_client_id",
    client_secret_value=self.google_cognito_secret.secret_value_from_json("google_client_secret"),
    scopes=["profile", "email", "openid"],
    user_pool=user_pool,
    attribute_mapping=attribute_mapping,
)