如何在不使用身份池/ IdentityPoolId的情况下对用户进行身份验证,仅使用用户池凭据? https://github.com/aws/amazon-cognito-identity-js使用Cognito用户池凭证对用户进行身份验证
实施例4中链接以上仅适用于/与身份池, 当我打电话例如方法
cognitoUser.changePassword('oldPassword', 'newPassword', function(err, result) {}
retrun我从CognitoUser.js误差,串602-604
if (!(this.signInUserSession != null && this.signInUserSession.isValid())) {
return callback(new Error('User is not authenticated'), null);
}
但是,当我打电话
cognitoUser.getSession(function(err, session) {if (err) {
alert(err);
return;
}
console.log('session validity: ' + session.isValid());
它给我会话令牌。
如何,我想验证用户:
const logins = {};
logins['cognito-idp.' + environment.region + '.amazonaws.com/' + environment.UserPoolId] = session.getIdToken().getJwtToken();
// Add the User's Id Token to the Cognito credentials login map.
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
Logins: logins
});
,让我错误
Argument of type '{ Logins: {}; }' is not assignable to parameter of type 'CognitoIdentityOptions'.
我想要实现:
1)如何理解cognito用户池用户身份验证没有身份池?
2)如何认证用户?
3)对象CognitoUser有2个propreties:
- 会议
- signInUserSession
又是为了什么? 如何正确使用它们?
P.S.当即时通讯使用这种方式,一切工作正常,但我需要达到它没有身份池
const creds = new AWS.CognitoIdentityCredentials({
IdentityPoolId: environment.IdentityPoolId, // your identity pool id here
Logins: {
// Change the key below according to the specific region your user pool is in.
[`cognito-idp.${environment.region}.amazonaws.com/${environment.UserPoolId}`]: session.getIdToken().getJwtToken()}},
{
region: environment.region
});
AWS.config.credentials = creds;
感谢解释,问题更新, 的getSession - >给我会话令牌idToken:CognitoIdToken,refreshToken:CognitoRefreshToken,的accessToken:CognitoAccessToken) getCurrentUser() - 给我的用户从localStorage的 –