InMemoryTokenManager info needed

Apr 7, 2010 at 3:54 PM

Hi, What is InMemoryTokenManager? I have googled and nothing of use comes up. 

How does it work? I am wondering what happens if multiple users hit the page at the same time? is this session related (IE tied to one user) or is it just memory related (accessible by multi users)? I am not keen on using something I don't understand so a doc link would be good :) . 

Also if I have the access token saved from a earlier call how to I reuse it?


Many thanks in advance.


Apr 8, 2010 at 1:15 PM

Hi Darren,

You're not supposed to use InMemoryTokenManager.  It's only there for the sample.  You need to implement the IConsumerTokenManager in your own class and pass that into LinqToTwitter.  Your implementation will save and retrieve the tokens from a database or some other persistent store. 

That may automatically answer your second question.

Apr 8, 2010 at 6:02 PM

Thanks Aarnott, I have found other references to this and it's not exactly clear how to implement this or what its actual purpose is, why was this not done via session's or profiles for instance? 

I need an example class and code to see how it works in action. The docs I found didn't have an example which I sorely need. 

If anyone has a working example of using this with sql server or even better using profiles then don't be shy and share :)


Apr 8, 2010 at 6:18 PM

If it were just done with ASP.NET sessions, all tokens would be lost when the user logged out, forcing your users to re-approve Twitter every time they visit your web site.  Profiles might make a reasonable store for this information, and if you're comfortable with that you can code up your IConsumerTokenManager implementation to use profiles to store this information.

The InMemoryTokenManager is your example class.  It works, except that it stores tokens in your web application memory rather than something persistent.  Since you define what is persistent for your web site (profiles in this case perhaps) that's where your responsibility begins.  If you have specific questions as you implement the interface that you can't answer from looking at the sample or from the interface's documentation, feel free to ask them.