9

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

thedreamsaver
  • 1,294
  • 4
  • 16
  • 27
  • Have you try the console cli ? https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/add-custom-attributes.html – bembas Mar 24 '19 at 11:02
  • 1
    I'm making an Alexa Skill and using cognito for logging in. Not sure where should I use the console cli for cognito. – thedreamsaver Mar 24 '19 at 18:53
  • 1
    @thedreamsaver I am currently going through the same issue right now.. Idk how to fix it, but I can definitely tell you that it has nothing to do with the console cli... Keeping my eye on this question as this will help me as well. – codeherk Mar 28 '19 at 05:14
  • 1
    Before I add any more edits to the question @thedreamsaver , I would like to ask you: 1. Are you trying to implement **Account Linking with Alexa Skill**? 2. Are you using their given **Authentication UI**? (Reason why I ask is because the detailed edit I made got rejected.) – codeherk Mar 28 '19 at 17:35
  • @codeherk 1. Yes I'm trying to implement Account Linking with Alexa Skill and I have added your edits to the question. 2. Yes I'm using their UI and need the custom attribute to show up in the sign up UI as well. – thedreamsaver Mar 31 '19 at 19:40
  • I’m using custom ui , is there any way I can get the custom attributes through api before sign up so that I can add required fields dynamically? – Srikanth Gowda May 10 '22 at 03:05

2 Answers2

4

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.

calabrone
  • 96
  • 2
  • 9
3

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@mydomain.com'
};

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.')
});