我想从 AWS 获取身份验证令牌; 然而,我只收到一个错误告诉我 客户端 ID 不正确。
我很高兴在网上找到了这段代码, 链接:https://docs.aws.amazon.com/cognito/latest/developerguide/authentication.html 我能够调用最后一个函数调用, 但它抱怨 ClientId,我不知道 从哪里获取 Clientid :-(
我不确定从哪里获取客户端 ID 和用户池 ID?
AWS 网站上还有一个客户端应用程序 ID。
我正在寻找我只需要提供的东西 使用 node js 的用户 ID 和密码?
const AmazonCognitoIdentity = require('amazon-cognito-identity-js');
var authenticationData = { 用户名 : '...', 密码 : '...', };
var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails(authenticationData);
var poolData = {
UserPoolId : '...', // From where on the AWS web site can I fetch the correct User Pool Id?
ClientId : '...' // From where on the AWS web site can I fetch the correct client Id?
};
var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
var userData = {
Username : 'karlschmitt',
Pool : userPool
};
var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
var accessToken = result.getAccessToken().getJwtToken();
/* Use the idToken for Logins Map when Federating User
Pools with identity pools or when passing through an
Authorization Header to an API Gateway Authorizer */
var idToken = result.idToken.jwtToken;
console. log("Successful!");
},
onFailure: function(err) {
// alert(err);
console. log("Failure!" + err.message);
},
});