How do I get the AccessToken&SecretToken without using username/password(callback)?



I am trying to get the Twitter Access Token & Secret Access Token from an already authenticated user ( facebook logged in ) on my site.
The user already authorized my app once and I have his permission to read/write his tweets.

So now the user is logged in via facebook and I would like to fetch his associated twitter access token via his user_id without that he has to go through the whole oauth auth flow.

Is there an API function like : Twitter->getAccessToken($TwitterID)? Similiar to Facebooks API?
I don´t want the user to be redirected to Twitterslandinpage and type in his/her password/username once again.

Thank you very much for help!


No, there’s no means for you to re-obtain an access token for a user that’s granted your application access. If you didn’t persist the values, you’ll need to re-obtain them. You may find the oauth/authenticate flow is better for you here though, as it will perform a redirect without prompting if the user is logged in and has already approved your application.


Are Twitter AcessTokens persistent? So if yes, that means I have to save his/her AccessToken and SecretToken inside my database, correct?

The function still requires username/password.

For Example using the Facebook API, I am able to just retrieve the the AcessToken by using facebook->getAccessToken($FacebookID), if the user has already gave permission to my app.


They are persistent until the user explicitly revokes them.

oauth/authenticate requires the user to enter their username and password only if a session isn’t already present in the web browser AND the user doesn’t have an active relationship with the application.



Ok then it seems that the only way to get them is to save them in my database. :slight_smile:


How to set callback URL? The localhost didn’t work.
I download a php and java libraries.
And change the properties.
And change callback URL to http://localhost or, both didn’t work.
Can you tell me the reason?
Thank you very much!


how can i get user’s access token and access token secret programmatically??..please help me…
thanks in advance


Dear Chandu!
You can find in on google search


Can you authenticate without prompting on android? Specifically in the case that the user is logged in the official twitter application for android.