Client app using Twitter and OAuth: Is my method correct?
I have an application that I've developed in .NET 4.0/C#. It's designed to be used by customers that want to watch hardware sensors and alert them of specific values. One option for notification is by "tweeting" to a Twitter account of their choice. Before Twitter changed to OAuth, users entered their account name and password and this was enough to send Tweets on their behalf.
After reading up on the Twitter API and OAuth, I want to see if I understand correctly the best way to maintain this functionality.
I've registered my application with dev.twitter.com and obtained the necessary Consumer Key and Consumer Secret.
The application may potentially need to tweet to mor开发者_Go百科e than one Twitter account as it is used by multiple users per installation.
If I understand things correctly I will need to do the following:
Provide some sort of "Request Authorization" button on a per-user basis, which launches a Twitter authentication web site. There, the user logs in and is then provided with a PIN number.
Use the PIN number to obtain the user's
AccessToken
andAccessTokenSecret
.Store both of these tokens between sessions (launches) of the application.
My questions:
Should I encrypt either of these tokens when storing (in SQL)?
Is it ever necessary to re-authorize? The program is intended to be setup just once, then run unattended. Re-authorizing accounts will be a deal-breaker.
Though it shouldn't affect any answers or advice, I am using the TweetSharp library.
Your understanding seems pretty good to me.
- It depends on how you store your consumer key and secret. If an attacker could gain those and the user's tokens, then that would be bad. The tokens aren't much use without your tokens too.
- Only if the user revokes their authorisation.
精彩评论