简体   繁体   中英

How to get temp credentials from Cognito Identity in AWS Lambda written in JAVA

I have an AWS Lambda Function written in java that is called by API gateway, which is Authenticated using AWS_IAM. The idea is user will use Cognito Federated pool to generate the credentials that will be passed while calling the API. Then Lambda function use
context['cognito-identity-pool-id']
['cognito-authentication-provider']
to call the AWS.CognitoIdentityCredentials and get the temp credentials.

I did this successfully in Node.js Lambda. Same logic should be done in Lambda written by Java. However I can't find any example of something equivalent to below code in node.js

let creds = new AWS.CognitoIdentityCredentials({
    IdentityPoolId: identityPoolId,
    Logins: {
        cognitoUserPoolId: idtoken
    }
});

You can find the documentation for this in Android docs. Most of the use cases for this implementation are on the untrusted front end side. So you will mostly find examples of that in the documentation. The former product manager of aws cognito answered this pretty well here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM