Take the 2-minute tour ×

I am using Oauth to create a way for users of our website to login using their twitter account. However, It's quite annoying that everytime they click to sign in with their twitter account they have to grant access each and every time.

Couldn't it work so that if it has been granted once they don't have to keep granting access? Therefore removing a step. I'm using the steps found in:


Thanks for any feedback!

share|improve this question

3 Answers 3

You need to start the token / token secret you get in a database or other long term storage method. Then you pass it into the object that does the OAuth authentication so you don't have to keep asking your user. With PHP you can store them in a MySQL or similar database and load them into $_SESSION when the user logs in to pass the values.

share|improve this answer
Forgive me if im wrong, but I don't think thats going to fix the problem. Example: Day 1: user comes to website, clicks login with twitter, logs into twitter, clicks 'sign in' to authroize website to talk with twitter account, sent back to website, all is good. Day 2: user comes back, clicks sign in with twitter, they have to authorize the app again. This is the step im trying to avoid. –  David May 11 '11 at 15:26

When the users connects, you receive an access token and a secret token, which are used every time you ask anything to the Twitter API.

If you wan't your users to stay connected to twitter, you only have to save in your database those two tokens. (They are user specific, don't use one token for every user). When you know these tokens, you don't need to ask the user to grant access, you can directly use them to call the API.

If a user removes rights for your application, you won't be able to use his tokens any more, and you will have to ask him to grant access a new time.

share|improve this answer
Again, see my comment on the other answer. The user isn't logged in at all on my site. I want them to click 'twitter' and if they have already authorized my app with their twitter account, then log them in. –  David May 11 '11 at 15:29
Ok, I understand better your problem. I'm sorry, I don't know the twitter API enough to answer this (in fact, I thought it would be automatically done by twitter) –  Guilac May 11 '11 at 15:34
up vote 12 down vote accepted

I found the answer after talking to some developers on twitterapi irc

Bascially I was going to https://twitter.com/oauth/authorize with all my oauth, what I need to do was go to https://twitter.com/oauth/authenticate instead. That then gives forever authorization.

share|improve this answer

Your Answer


