0

私はCognito Amazon Webserviceを使用してユーザー管理を行っています。AngularJSのAWS Cognitoログインエラー

私はすでに、私はこのコンソールのエラーをした私は、ユーザプールにログインしようとしている私のuserPoolが、毎回の署名を管理:

Error: this.pool.getUserPoolId is not a function 

getUserPoolIdからです私は知りません...

編集:私は私のコードの工場で私のログイン機能をしました:

login: function(username, password) { 
     var authenticationData = { 
       Username : username, 
       Password : password 
     }; 
     var userData = { 
       Username :username, 
       Pool : poolData 
     }; 
     var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData); 

     var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData); 
     cognitoUser.authenticateUser(authenticationDetails, { 
     onSuccess: function (result) { 
      console.log('access token + ' + result.getAccessToken().getJwtToken()); 
      /*Use the idToken for Logins Map when Federating User Pools with Cognito Identity or when passing through an Authorization Header to an API Gateway Authorizer*/ 
      console.log('idToken + ' + result.idToken.jwtToken); 
    }, 

    onFailure: function(err) { 
      alert(err); 
    }, 

     }); 
     } 

は何をすべきか、誰を知っていますか?

+0

私たちは、この質問の背景を理解するためのコードが必要になります。 – jonode

+0

Thansk質問を編集しました。 – rastafalow

答えて

0

AWS CognitoのJavaScript SDKの初期化パターンを使用すると、AWS SDKのコンストラクタに、「データ・オブジェクト」を渡す必要があります。 SDKでは、さまざまな接続方法を使用してAWSの「インターフェイス」を提供します。

あなたのコードから、data objectを次のinterfaceの代わりに使用したと思います。

例:あなたが提供するコードで

// Data Object used for initialization of the interface 
const userPoolData = { 
    UserPoolId: identityPoolId, 
    ClientId: clientId 
} 

// The `userPoolInterface`, constructed from your `poolData` object 
const userPoolInterface = new AWSCognito 
    .CognitoIdentityServiceProvider 
    .CognitoUserPool(userPoolData) 

、あなたが以前に初期化されている必要がありますuserPoolインタフェースを渡すべきである(初期化に使用される)userDataオブジェクトを渡しているようです。

は、代わりにこれを試してみてください:

login: function(username, password) { 

    // 1) Create the poolData object 
    var poolData = { 
     UserPoolId: identityPoolId, 
     ClientId: clientId 
    }; 

    // 2) Initialize the userPool interface 
    var userPool = new AWSCognito 
     .CognitoIdentityServiceProvider 
     .CognitoUserPool(poolData) 

    // 3) Be sure to use `userPool`, not `poolData` 
    var userData = { 
     Username : username, 
     Pool : poolData, // <-- Data?! Oops.. 
     Pool : userPool // "interface", that's better :) 
    }; 

    var authenticationData = { 
     Username : username, 
     Password : password 
    }; 

    var cognitoUser = new AWSCognito 
     .CognitoIdentityServiceProvider 
     .CognitoUser(userData) 

    var authenticationDetails = new AWSCognito 
     .CognitoIdentityServiceProvider 
     .AuthenticationDetails(authenticationData); 

    cognitoUser.authenticateUser(...etc...); 
} 

はそれをオンラインで試してみてください。それが助け場合、私はAWS Cognito SDKの例を歩きながら

を、私は、メモを取ると例を作っています。私が使っているGithubレポをチェックアウトすることは大歓迎です。実際の例を試すことができれば役に立ちます。

Github Repository /Live Demo

0

私はあなたがあなたのpoolDataオブジェクトを初期化していると仮定します。

var poolData = { 
    UserPoolId : '...', // Your user pool id here 
    ClientId : '...' // Your client id here 
}; 
+0

はい、もちろんあります – rastafalow