2016-04-08 15 views
0

カスタム開発者プロバイダ名 "my.developer"を使用してCognito IDプールを設定しました。私のノードラムダ関数から私は、次のコードを呼び出す:getOpenIdTokenForDeveloperIdentity: "これらの資格情報はこのリソースへのアクセスには有効ではありません"

AWS.config.region = 'ap-northeast-1'; // Region 
AWS.config.credentials = new AWS.CognitoIdentityCredentials({ 
    IdentityPoolId: 'ap-northeast-1:*****' // I am using a valid UUID here 
}); 
var cognitoidentity = new AWS.CognitoIdentity(); 

var params = { 
    IdentityPoolId: 'ap-northeast-1:*****', 
    Logins: { 'my.developer': 'test-user' } 
}; 
cognitoidentity.getOpenIdTokenForDeveloperIdentity(params, 
    function(err, data) { 
     console.log('error:', err); 
     console.log('data:', data); 
    } 
); 

...私はエラーを取得する機能をテストするとき:

{ 
    "errorMessage": "These credentials are not valid for accessing this resource", 
    "errorType": "AccessDeniedException", 
    "stackTrace": [ 
    "Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:43:27)", 

を私は両方が似ているCognito_Unauth_RoleとCognito_Auth_Roleを持っています

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
     { 
      "Effect": "Allow", 
      "Action": [ 
       "mobileanalytics:PutEvents", 
       "cognito-sync:*", 
       "cognito-identity:*" 
      ], 
      "Resource": [ 
       "*" 
      ] 
     } 
    ] 
} 

...私は何が欠けていますか?

答えて

1

あなたのラムダ関数の実行の役割は、(これはない Cognito_Unauth_Role、またCognito_Auth_Role、それが実行されている間、あなたのラムダ関数が使用する役割である)Cognitoサービスのための十分な権限を持っていること。確認してください例えば、ポリシーは、次のようになります。

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
     { 
      "Effect": "Allow", 
      "Action": [ 
       "cognito-sync:*", 
       "cognito-identity:*" 
      ], 
      "Resource": [ 
       "*" 
      ] 
     } 
    ] 
} 
0

不思議なことに、次の行は、問題を修正削除:

AWS.config.credentials = new AWS.CognitoIdentityCredentials({ 
    IdentityPoolId: 'ap-northeast-1:*****' // I am using a valid UUID here 
}); 

...私はCognitoIdentityCredentialsを作成することによって、それが削除されていラムダ関数内のオブジェクトと推測しますロールをWebコンソール内で構成します。

関連する問題