Server-side verification of Twitter login from iPhone

So, I currently implemented Facebook login in my application as follows:

I use the official FB structure to log in the user system. When I log in, I get an authentication token that is sent to my server. Then I do another user check (for example, get an ā€œIā€ from Facebook using an authentication token), and then return a 32 char random key, which is used to identify the user in subsequent API calls (to my server). An example .

I'm trying to figure out how to do the same with twitter, but I can't figure out how to get the oath token in iOS? My part on the server side is working in another application, but there is no token to check ...

Please advise - this (FB method), how should I do this, or how will you go through the verification process?

+7
source share
3 answers

Sean Cook, @Twitter engineer has a github repo with a simple application that does exactly what you are trying to do, the code in my application, and it works like a charm.

+1
source

There's a good article at dev.twitter.com describing just that. Basically, you first need to get a special request token by setting the x_auth_mode parameter to reverse_aut , and then get the appropriate access token by sending what you received in the first step as x_reverse_auth_parameters .

+1
source

If you intend to use the iOS 5 solution, you can import it into the header file.

  #import < Twitter/TWTweetComposeViewController.h > 

and then in the .m file where you want to authenticate

 if ([TWTweetComposeViewController canSendTweet]) { TWTweetComposeViewController* twc = [[TWTweetComposeViewController alloc] init]; [twc addImage:uiImage [self presentModalViewController:twc animated:YES]; twc.completionHandler = ^(TWTweetComposeViewControllerResult result) { if (result == TWTweetComposeViewControllerResultCancelled) NSLog(@"Tweet compostion was canceled."); else if (result == TWTweetComposeViewControllerResultDone) NSLog(@"Tweet composition completed."); // Dismiss it [self dismissModalViewControllerAnimated:YES]; }; [twc release]; } else { //can't tweet } 

You can also add URLs, text, and other types of information.

Edit: you can find a tutorial on adding the necessary library to your project here, https://dev.twitter.com/docs/ios/how-add-twitter-framework-your-ios-project

-2
source

All Articles