I've been trying to figure out exactly how digg.com and other similar sites deal with authentication via oauth. Creating an account via oauth is pretty straight forward, the user clicks the twitter/facebook connect button which then digg sends our a secret and if everything works, this secret is returned and gets stored as the access token.
However, how does authentication work this way? When I click on the login via twitter button for example, a random secret is being sent to twitter. Does twitter instead return the prior access token or does digg get the twitter user id for example, compare it to a stored value in the db and then uses the stored access token from there?
For example: 1. user clicks login via twitter. 2. a secret is sent, twitter does some processing and returns info such as username/id/etc... 3. based on one of these return values, the db is polled and the user rows are loaded, authentication succeeds.
Am I way off on this? Can someone please enlighten me?