Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get custom attributes on AWS Cognito sign up form?

I am building an Alexa Skill that will implement Account Linking. When a user uses my skill, they would have to use the Alexa App to sign-in.

The Authentication UI is set up and managed by Amazon Cognito so that I don’t have to host my own sign-in and sign-up UI for my Alexa application.

My User Pool in Cognito has two standard and one custom attribute.

The sign-up form (hosted by Cognito) includes text-fields for the standard attributes, but not for the custom attributes. I want text-fields for all attributes (standard and custom). I couldn't find any documentation that shows how to allow this. How do I do it?

I have two standard and one custom attributes. I need all of them from user.

But the sign up form is not showing the input field for custom attribute

like image 920
thedreamsaver Avatar asked Mar 23 '19 22:03

thedreamsaver


People also ask

How do I get user attributes from Cognito?

To view user attributes From the Amazon Cognito home page in the Amazon Web Services Management Console, choose Manage user pools. Choose your user pool from the Your User Pools page. Choose User and Groups to view user information. Choose a user name to show more information about an individual user.

How do you change attributes on Cognito?

You can't change standard user pool attributes after a user pool is created. Instead, create a new user pool with the attributes that you want to require for user registration. Then, migrate existing users to the new user pool by using an AWS Lambda function as a user migration trigger.

Can AWS Cognito be used for SSO?

Single Sign-On (SSO) solutions allow users to enter credentials once and access many systems simultaneously. IT administrators can use a local SSO server or a third-party service to manage authentication, allowing for centralized access management.

How do I customize my verification email on Amazon Cognito?

To customize the email subject and message content for email address verification messages, edit the template under the Do you want to customize your email verification messages? heading. If you choose code as the verification type, your custom message must contain the {####} placeholder.


2 Answers

I was interested too, but i think is not possible using the Login Web Page hosted by Amazon cognito. I've found this information on Amazon Cognito guide: https://docs.aws.amazon.com/en_us/cognito/latest/developerguide/cognito-user-pools-app-integration.html

At the end of this document i've found:

Note

The Amazon Cognito hosted sign-in web page does not support the custom authentication flow.

like image 96
calabrone Avatar answered Sep 28 '22 03:09

calabrone


If i am not mistaken you need to add custom:<YOUR_ATTRIBUTE_NAME>

var poolData = {
    UserPoolId : <POOL_ID>,
    ClientId : <CLIENT_ID>,
};
var userPool = new AWSCognito.CognitoUserPool(poolData);

var attributeList = [];

var dataEmail = {
    Name : 'email',
    Value : '[email protected]'
};

var dataPhoneNumber = {
    Name : 'phone_number',
    Value : '+15555555555'
};
var grandMaName = {
    Name : 'custom:grandMaName',
    Value : 'granny'
};
var attributeEmail = new AWSCognito.CognitoUserAttribute(dataEmail);
var attributePhoneNumber = new AWSCognito.CognitoUserAttribute(dataPhoneNumber);
var attributeGrandMaName = new AWSCognito.CognitoUserAttribute(grandMaName);
attributeList.push(attributeEmail);
attributeList.push(attributePhoneNumber);
attributeList.push(grandMaName);

userPool.signUp(userData.Username, userData.Password, attributeList, null, function(err, result){
    if (err) {
        console.log(err);
        return;
    }
    cognitoUser = result.user;
    console.log('user name is ' + cognitoUser.getUsername());
    console.log('Now go to Cognito console and confirm the user.')
});
like image 31
Dawid Kisielewski Avatar answered Sep 28 '22 02:09

Dawid Kisielewski