0

ユーザープールの資格情報でのみ、IDプールなしでユーザーを認証する方法/ IdentityPoolId?私は私retrun例の方法Cognitoのユーザープールの資格情報でユーザーを認証します。

cognitoUser.changePassword('oldPassword', 'newPassword', function(err, result) {} 

ためCognitoUser.jsからのエラーを呼び出すときに、リンクで https://github.com/aws/amazon-cognito-identity-js

例4は、上記の文字列、アイデンティティプール、 で/だけのために働く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()); 

それは私にセッショントークンを与えます。私は

Argument of type '{ Logins: {}; }' is not assignable to parameter of type 'CognitoIdentityOptions'. 

は、私が達成しようとしているどのようなエラー与える

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

::私は、ユーザーを認証しようとしている方法

どのようにcognitoを理解することが

1)アイデンティティプールなしで認証されたユーザープールユーザー

2)ユーザーの認証方法は?

3)オブジェクトCognitoUserは2 propretiesいる :

  • セッション
  • signInUserSession

彼らは何ですか? 正しく使用するには?

P.S.このように使用すると、すべて正常に動作しますが、IDプールなしで達成する必要があります

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; 

答えて

0

最初に達成しようとしていることは何ですか?アイデンティティプール、アイデンティティプールIDは、Cognito Federated Identitiesのコンテキストで使用されます。 Cognito Federated Identitiesは、Facebook、Google、Cognito User Poolsなどの異なるアイデンティティプロバイダと連携してAWS Credentialsを販売するために使用されます。

あなたが指摘したSDKは、Cognito User PoolsのSDKです。ユーザープールは、認証に使用できるユーザーデータのディレクトリとみなすことができ、CognitoフェデレーションIDのアイデンティティプロバイダです。

ユーザープール(ユーザーは認証する必要があります)のコンテキストで認証されたメソッドであるchangePasswordを呼び出すメソッドです。 GetSessionはローカルストレージから現在のユーザーを取得するだけです。あなたのユースケースは正確に何ですか?達成しようとしているのは何ですか?

+0

おかげで、問題は、更新され のgetSession - >セッションがidTokenトークン私を与える:CognitoIdToken、refreshToken:CognitoRefreshToken、accessToken:()CognitoAccessToken) GETCURRENTUSERを - でのlocalStorage –

0

あなたのログインマップには、以下のようなマップがあるのに対し、配列を含むマップがあります。説明のための

  Logins : { 
       // Change the key below according to the specific region your user pool is in. 
       'cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID>' : result.getIdToken().getJwtToken() 
      } 
+0

問題ありませんから、私にはないが、ユーザーを与えますこの –

関連する問題