Closed ellier closed 6 years ago
I think the error is that you haven't defined AWSCognito. The following works for me in node:
var cognito = require('amazon-cognito-identity-js');
var poolData = { UserPoolId : 'YOUR_USER_POOL_ID',
ClientId : 'YOUR_CLIENT_ID'
};
var userPool = new cognito.CognitoUserPool(poolData);
var authenticationData = {
Username : 'YOUR_USERNAME',
Password : 'YOUR_PASSWORD',
};
var authenticationDetails = new cognito.AuthenticationDetails(authenticationData);
var userData = {
Username : 'YOUR_USERNAME',
Pool : userPool
};
var cognitoUser = new cognito.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
console.log('access token + ' + result.getAccessToken().getJwtToken());
},
onFailure: function(err) {
console.log('error ' + err);
},
});
Thanks for your reply. That worked.
I'm still wondering why I'm getting this AWSCognito undefined error when I'm just following the examples here.
You're following the examples for script usage. If you look, there's a disclaimer saying: "The usage examples below use the unqualified names for types in the Amazon Cognito Identity SDK for JavaScript. Remember to import or qualify access to any of these types:"
I did all that and I'm still having the same issue. What am I missing?
I'm not entirely sure I understand the issue at this point. My node example is working for you and I've explained that it's only in script usage that we namespace everything to AWSCognito. For node usage (as mentioned in the docs), you would have to require the objects from the corresponding modules, and you just haven't defined AWSCognito anywhere.
I'm getting this error while trying the Use Case #4:
Here is the code, which is basically what I copied and pasted from here:
I'd really appreciate any help here. Thanks.