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

**URL:** <https://community.auth0.com/t/aws-lambda-and-api-gateway-how-to-get-a-users-twitter-access-token-key-access-token-secret-from-its-sub-id/8438>\
**Category:** Get Help\
**Tags:** api-gateway, aws, lambda, access-token, custom-authorizer\
**Created:** [October 10, 2017, 6:01pm UTC](https://community.auth0.com/t/aws-lambda-and-api-gateway-how-to-get-a-users-twitter-access-token-key-access-token-secret-from-its-sub-id/8438 "2017-10-10T18:01:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![behrangsa](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@behrangsa](https://community.auth0.com/u/behrangsa)\
**Post date:** [October 10, 2017, 6:01pm UTC](https://community.auth0.com/t/aws-lambda-and-api-gateway-how-to-get-a-users-twitter-access-token-key-access-token-secret-from-its-sub-id/8438/1 "2017-10-10T18:01:19Z")

</div>

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](https://github.com/auth0-samples/jwt-rsa-aws-custom-authorizer/blob/master/lib.js#L71) 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.

---

<div class="post-metadata">

**Author:** ![behrangsa](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@behrangsa](https://community.auth0.com/u/behrangsa)\
**Post date:** [October 10, 2017, 7:16pm UTC](https://community.auth0.com/t/aws-lambda-and-api-gateway-how-to-get-a-users-twitter-access-token-key-access-token-secret-from-its-sub-id/8438/2 "2017-10-10T19:16:07Z")

</div>

Looks like the context ([jwt-rsa-aws-custom-authorizer/lib.js at master · auth0-samples/jwt-rsa-aws-custom-authorizer · GitHub](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?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/aws-lambda-and-api-gateway-how-to-get-a-users-twitter-access-token-key-access-token-secret-from-its-sub-id/8438/3 "2018-03-02T05:56:54Z")

</div>


