Auth0 Home Blog Docs

AWS Lambda and API Gateway: How to get a user's Twitter access token key/access token secret from its sub ID?

access-token
aws
lambda
api-gateway
custom-authorizer

#1

When adding authentication to an AWS Lambda function using a Custom Authorizer, the authorizer will create an IAM policy with a principal ID that according to this example, the principal ID should be set to the Auth0 sub field.

If I am not wrong, the only information about the authenticated user that is passed through to the target Lambda function is this principal ID.

My question is: inside the Lambda function, how can I obtain the Twitter access token/access token secret values for the authenticated user – if the user has authenticated and/or linked his Twitter account – so that my Lambda function can post tweets on behalf of the user?

Thanks in advance.


#2

Looks like the context (https://github.com/auth0-samples/jwt-rsa-aws-custom-authorizer/blob/master/lib.js#L73) is also passed to the Lambda function.
But the question still remains: How to retrieve the authenticated user’s Twitter access token/access token secret (and maybe even the Twitter app’s consumer key/secret) from the Lambda function?


#3