AWS JS SDK의 공식 레포에서 발견 된이 코드 조각을 사용했습니다. 사용자를 인증하는 데 사용됩니다.AWS Cognito 인증 할 수 없음 : 빈 대답 - JS SDK
빈 응답이 반환됩니다.
AWSCognito.config.region = 'us-east-1';
var authenticationData = {
Username : '+1112223333', //some phone number used as an Alias
Password : 'password123456',
};
var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
var poolData = {
UserPoolId : 'us-east-1_P00l1d', // Your user pool id here
ClientId : 'xxx' // Your client id here
};
var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
var userData = {
Username : 'myusername',
Pool : userPool
};
var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
console.log('access token + ' + result.getAccessToken().getJwtToken());
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId : 'xxx', // your identity pool id here
Logins : {
// Change the key below according to the specific region your user pool is in.
'cognito-idp.pool_id_number_here_xxx' : result.getIdToken().getJwtToken()
}
});
},
onFailure: function(err) {
alert(err)
console.log("Error " + err);
},
});
authenticationData의 경우 사용자 이름 (전화 번호는 별칭으로 설정 됨)과 암호로 전화 번호를 사용했습니다. 나는 사용자 이름으로 직접 시도했다. 전화 번호를 등록하고 확인하는 데 동일한 값을 사용 했으므로 UserPoolId 및 ClientId가 정확합니다. userData에서 사용자 이름을 적절한 myusername으로 설정합니다.
ID 풀에 관해서, 필자는 내 App과 내 UserPool에 연결된 AWS Console에 Identity 풀을 만들고 identityPoolId 및 LogininsecurityUser 값을 대체했습니다. 로그인의 가치에 대해서는 완전히 확신 할 수 없습니다. 나는 cognito-idp.POOLIDNUMBER를 사용했습니다.
AWS의 출력이 비어 있습니다. 나는 심지어 서버에 연결할 수 없다고 생각하고 있으며 역할이나 Identity Pool (userPool은 괜찮습니다) 문제를 의심합니다.
내 ID 풀은 Facebook 또는 다른 ID 공급자가 아닌 AWS Cognito 사용자 만 사용합니다.
편집 또는 댓글이어야합니다. 대답이 없습니다. – Deep