I've implemented the oAuth in php (currently for twitter) and as I've read in several tutorials you should store the access token in db for future use. However I don't see how you know if you have the access token stored for a particular user to decide if you should pull it out of the db or regenerate it. Here's a flow describing my question:
First time user signs in:
- get request token
- send user to provider's authentication page
- user returns to callback url with oauth token and oauth verifier
- get access token
- save access token/user_id/screen_name on db for future use
User returns 10 minutes later:
- access token is still in server session vars if user didn't log out. else, repeat process.
User returns 1 month later:
- get request token
- send user to provider's authentication page
- user returns to callback url with oauth token and oauth verifier
- ( at this point I only have oauth tokens, how can I know if the user has previously logged in with twitter and pull their access token from db? )
- if it is the user's first loggin, generate access token.
The main workflow for oAuth is clear, however it is not clear how to handle returning users and which data should be stored or not.
A million thanks!