Created
March 6, 2018 04:58
-
-
Save trylovetom/f1067271e71b46be5e2618aa5228f755 to your computer and use it in GitHub Desktop.
CognitoAuthLoginLambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Loading Function') | |
// Dependencies | |
const AWS = require('aws-sdk') | |
// Functions | |
const getToken = userId => { | |
const cognito = new AWS.CognitoIdentity({ apiVersion: '2014-06-30' }) | |
const params = { | |
IdentityPoolId: '...', | |
Logins: { | |
'login.alljoint.CognitoAuth': userId | |
} | |
} | |
return cognito.getOpenIdTokenForDeveloperIdentity(params).promise() | |
} | |
exports.handler = (event, context, callback) => { | |
const userId = 'UserA' | |
getToken('UserA') | |
.then(data => { | |
const response = { | |
statusCode: 200, | |
body: JSON.stringify({ | |
message: 'Success', | |
userId, | |
data, | |
input: event | |
}, null, 4) | |
} | |
callback(null, response) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment