Ok, I really know what is it. I work with Facebook/Twitter API long ago. And it works, there is no bugs, sorry :). However, the following thing haunts me.
What is a token from OAuth provider side? I see token from client side only. But there is one interesting thing. It's easy to understand.
By default the token I recieve is limited in time. However, when I request an API with offline acces the token I recieve will work eternally with no time limits. Should the token be stored in OAuth provider database in this way? If so, what prevents users to generate milliards of tokens? What if there are a lot of tokens and all of them are stored in database with no time limits? Database then becomes a trash heap. Is this a true way?
I have two assumptions of how tokens are stored:
Token is a simple id for the set of the access rights assign to it, each token being stored on OAuth provider side.
The token is an independent concept. The access rights is being encrypted and packed into the token and then being decrypted on the provider side. Th token lifetime is also packed into it
The second question. What is the best way to store tokens if I'll want develop my own OAuth provider?