views:

273

answers:

3

Hello,

For an iPhone app, I'm working on a feature that allows users to make automated tweets which are posted by a server (if they'd like to allow it). I've chosen to use OAuth for Twitter authentication.

I've successfully gotten permission using OAuth for the app itself to post directly, and I can easily see how I could have users authenticate and give the server permission directly using a web browser (or a UIWebView), with the server responsible for the OAuth functions.

But, my research into whether it is possible for the client to obtain the OAuth permissions and then pass them to the server which would then be allowed to use them to write tweets (in the way that you can obtain session proxy permissions for Facebook) has come up empty. Is this actually possible to do with OAuth/Twitter, or does it defeat the purpose of OAuth (or is it unsupported by Twitter)? Or is it just as simple as sending the server the OAuth token info which the client obtained? I'm trying to spec out what support is going to be necessary on the server side before proceeding with the client code but I'm somehow not finding examples of similar proxy tweeting out there.

Thanks for any help!

A: 

Seems that what you are wanting to do is possible, but I don't think it's advisable. If you do it server side, you will have to proxy everything and manage access tokens to twitter by unique identifier from each phone. You would probably be better off building a twitter client into your app and have each user authenticate with twitter to support your app directly. You can then log user activity to your server but the authentication process is something you won't have to care about. Once the user has granted your app access, you can do whatever you want with their data.

Best regards,

Matt Long
+2  A: 

I'm doing the same thing with the Foursquare API which also uses OAuth. I'm simply having the user authorize my app on their iPhone, then passing the user-specific OAuth tokens to my server. On the server I'm persisting the tokens related to iPhone device IDs. Later, the server is what actually talks to Foursquare to do updates.

I don't see why this wouldn't work with Twitter, however unless you have a really good reason to do it on the server, you should just do it from the user's iPhone. Adding another system in is always something you want to avoid.

bpapa
+1  A: 

I just posted a solution this question on another thread:

http://stackoverflow.com/questions/1064970/iphone-mgtwitterengine-post-a-tweet-with-my-app-signature/2095203#2095203

Smendrick
Hi Smendrick,Ben Gottlieb's Twitter Oauth was ultimately my solution as well, thanks for posting here and reminding me to follow up. The app obtains the tokens and passes them to the server.
Halle