# How to access to user token and token\_secret Twitter

**URL:** <https://community.auth0.com/t/how-to-access-to-user-token-and-token-secret-twitter/38524>\
**Category:** Get Help\
**Created:** [February 26, 2020, 5:31pm UTC](https://community.auth0.com/t/how-to-access-to-user-token-and-token-secret-twitter/38524 "2020-02-26T17:31:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pippocicirelli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pippocicirelli/32/19428_2.png) [@pippocicirelli](https://community.auth0.com/u/pippocicirelli)\
**Post date:** [February 26, 2020, 5:31pm UTC](https://community.auth0.com/t/how-to-access-to-user-token-and-token-secret-twitter/38524/1 "2020-02-26T17:31:37Z")

</div>

Hi, I used [this guide](https://auth0.com/docs/connections/adding-generic-oauth1-connection?&_ga=2.259469198.564227038.1582657563-2146598467.1582657563#using-your-new-connection) to create a personalized Twitter connection that uses oauth1.

Once logged in I can only view the accessToken and idToken, the information I need is the **token** and **token\_secret** of the logged in user.

[Link documentation Twitter OAuth1.0a](https://developer.twitter.com/en/docs/basics/authentication/oauth-1-0a)

how do I get them?

Thank you

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 27, 2020, 10:01pm UTC](https://community.auth0.com/t/how-to-access-to-user-token-and-token-secret-twitter/38524/3 "2020-02-27T22:01:26Z")

</div>

Hi @pippocicirelli,

Have you tried following this doc:

> **[Identity Provider Access Tokens](https://auth0.com/docs/secure/tokens/access-tokens/identity-provider-access-tokens)**
>
> Understand third-party access tokens issued by identity providers after user authentication and how to use them to call the third-party APIs.

Let me know,  
Dan

---

<div class="post-metadata">

**Author:** ![thomas.osborn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thomas.osborn/32/22282_2.png) [@thomas.osborn](https://community.auth0.com/u/thomas.osborn)\
**Post date:** [March 9, 2020, 11:51pm UTC](https://community.auth0.com/t/how-to-access-to-user-token-and-token-secret-twitter/38524/4 "2020-03-09T23:51:20Z")

</div>

Hi [pippocicirelli](http://community.auth0.com/u/pippocicirelli)!

It looks to me like these would come through the script you defined for the getUserProfile function:

```auto
function(token, tokenSecret, ctx, callback){

```

so although have no tried that myself, I’m assuming you the token and tokenSecret are what you are after.

Please let me if know that works for you.

---

<div class="post-metadata">

**Author:** ![pippocicirelli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pippocicirelli/32/19428_2.png) [@pippocicirelli](https://community.auth0.com/u/pippocicirelli)\
**Post date:** [March 12, 2020, 1:37pm UTC](https://community.auth0.com/t/how-to-access-to-user-token-and-token-secret-twitter/38524/5 "2020-03-12T13:37:24Z")

</div>

Hi @thomas.osborn,

exact! It seems that this information is stored and then accessible only by an api [https://DOMAIN/api/v2/users/USER\_ID](https://DOMAIN/api/v2/users/USER_ID) under the json entry:

“identities”: [  
{  
“provider”: “oauth1”,  
“access\_token”: “ **ACCESS\_TOKEN\_TWITTER** ”,  
“access\_token\_secret”: “ **ACCESS\_TOKEN\_SECRET\_TWITTER** ”,  
“user\_id”: “USER\_ID”,  
“connection”: “custom-twitter”,  
“isSocial”: true  
}  
]

I would like the Twitter token and secret to be returned after the user performs the login operation:

this.Client.authorize(options, (err, **authResult** ) =\> {  
}

So in **authResult** together with the accessToken, expiresIn, tokenType information is it possible to add also the Twitter tokens? Possibly I would like to avoid adding this information to the jwt token.

Thank you

---

<div class="post-metadata">

**Author:** ![thomas.osborn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thomas.osborn/32/22282_2.png) [@thomas.osborn](https://community.auth0.com/u/thomas.osborn)\
**Post date:** [March 12, 2020, 11:28pm UTC](https://community.auth0.com/t/how-to-access-to-user-token-and-token-secret-twitter/38524/6 "2020-03-12T23:28:45Z")

</div>

Hi [pippocicirelli](http://community.auth0.com/u/pippocicirelli),

I didn’t try this with Yahoo, but at least with Google connections when the rule runs the access token is available in the identities array of the user object.

If the token and token secret are also visible in the identities array from within a rule, you could send them back with the access token or ID token, or post them somewhere.

Does that make sense? Please let me know if that works.

---

<div class="post-metadata">

**Author:** ![pippocicirelli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pippocicirelli/32/19428_2.png) [@pippocicirelli](https://community.auth0.com/u/pippocicirelli)\
**Post date:** [March 13, 2020, 8:12am UTC](https://community.auth0.com/t/how-to-access-to-user-token-and-token-secret-twitter/38524/7 "2020-03-13T08:12:30Z")

</div>

It makes sense, for now I managed to create a RULE that does something like this:

![rule](https://global.discourse-cdn.com/auth0/original/3X/6/4/64389975270bcf90e5fd6d3b6d3a1023b1c9f6fd.png)

function (user, context, callback) {

```
context.idToken['https://example.com/access_token'] = user.identities[0].access_token;
context.idToken['https://example.com/access_token_secret'] = user.identities[0].access_token_secret;

```

I don’t like this solution, because it inserts the twitter tokens into the jwt contained in the idToken parameter.

What I would like to do is hang Twitter tokens to the token response generated by auth0. How can I do?

---

<div class="post-metadata">

**Author:** ![thomas.osborn](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thomas.osborn/32/22282_2.png) [@thomas.osborn](https://community.auth0.com/u/thomas.osborn)\
**Post date:** [March 17, 2020, 9:36pm UTC](https://community.auth0.com/t/how-to-access-to-user-token-and-token-secret-twitter/38524/8 "2020-03-17T21:36:55Z")

</div>

Uou either have to do what you’re doing now, or make a separate request to the management API. I understand why it would be useful to return the third party IdP token as just another part of the response, but it can’t be done.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 1, 2020, 1:37am UTC](https://community.auth0.com/t/how-to-access-to-user-token-and-token-secret-twitter/38524/9 "2020-04-01T01:37:00Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
