Twitter authentication problems - iphone

i am doing an application to upload photos and comments to twitter using twit pic.But when the user enter their twitter username and password,they give a pin number and the user have to enter this pin number everytime when he uses this application.Any way to overcome this problem of entering pin number all the time?please help

I assume the PIN is from the OAuth flow. You can either:
A. Detect when the Twitter pin is displayed, do a screen-scrape for the PIN value, then do the necessary processing.
B. Use a custom value for your OAuth callback for example: oauth://callback and have your app handle the callback. That way you don't have to use the out-of-band (PIN) flow.

The Mobile pin number auth flow is mainly intended for devices that don't have full keyboards or have limited web browsers (feature phones).
Add a parameter called oauth_callback when loading the login page and when the user logs in and web view finishes loading you can detect the callback url and extract the oauth_verifier key which can then be exchanged for OAuth Tokens that your application can save. https://dev.twitter.com/docs/api/1/post/oauth/access_token
For more information on login flow check out the twitter dev site: https://dev.twitter.com/docs/auth/oauth
Also you are targeting iOS 5 you can uses the built in Twitter.framework and TWTweetComposeViewController to send images directly to twitter.
P.S I'm the developer of HootSuite for iPhone / iPad. http://hootsuite.com/iphone

Related

How to do login with TWRequest in a user friendly manner?

After having a look at Apple TWRequest class (and example), I was surprised it has no possibilities for presenting a user with a login screen. The only way is to check if a user has entered its credentials with [TWTweetComposeViewController canSendTweet] and if no then give a message like
"Hey, you have manually to go to settings->twitter and enter the credentials. Then you should find and open our app manually and continue on"
I'm wondering does anybody use such crap functionality :) For example, Facebook iOS SDK 3 has implemented Single Sign On (SSO) that opens Safari with Facebook login screen and returns to your app after login... I guess I will need to fallback to old styled twitter integration with a lot of 3rd party stuff.
ps. I would give a try to ShareKit but I need to integrate my app with google+ which is not currently supported in ShareKit.

For desktop applications, how to get Facebook access_token from Browser?

I'm writing a Facebook plugin for my desktop application. Once user authorizes application, the access token will be appended to callback URL. If I will use regular browser (I don't like to use any html module in my app), then question is how can I get that token back to my desktop program?
Thanks!
With the Device flow, a user presses a button on their device. The device then displays a short code generated by Facebook, and the user then types this code into Facebook in a standard web-browser in order to authorize that device to access their Facebook data.
Please note that we are currently testing Device Authentication with a limited number of partners. It is not currently available for general use, and we are not accepting additional applications for access.
http://developers.facebook.com/docs/authentication/devices/

Twitter Callback Issue Using Titanium OAuth Client for Android

I'm using the following Titanium OAuth Client for a Share with Twitter feature in our Android app:
https://github.com/jeremyspouken/Titanium-OAuth-Client
The client works till the PIN Code screen. Then, if I have a callback URL defined in my Twitter App settings, it will redirect the user to that URL.. which I don't want. I read elsewhere that to disable the callback, to set oauth_callback=oob, which also is undesirable as it closes the Twitter screen after the PIN Code screen without having done anything.
Can someone help me understand what's the point of callback in Twitter oAUTH for mobile application, and how to make it work with my Titanium Andoid mobile app? I am about to pull my hair out.
Redirect url can come in handy if you say want to promote your app or want the user who logs in to twitter via your app.
e.g for say angry birds, if you login to twitter then the redirect url can be say the angry birds twitter page.
you can prevent the closing of the web view by simply removing the call that destroys authorize UI from your oauth_adapter file.
not sure if this helps you. just let me know the comments if it does or not.

How to make twitter login simpler by using PlainOAuth

I'm using PlainOAuth to post image to twitpic and post message to twitter home page from my iPhone app. Everything is ok, but the way user login to twitter is complex with user.
At first, user must select login flow: Pin, URL callback (URL callback seem not working, tested on simulator iOS 4.1)
Go to twitter login page to enter username and password.
Receiving pin code and return back to previous page to enter pin code.
How can I modify to make them simpler? I mean that can I just need to have a login page that allow user enter username and password (ignore enter pin step)?
I can see a lot of apps that have a very simply login way to twitter. Anyone has solution for this, please help!
Thanks in advance.
Tien
You need to register your app for xAuth with twitter.com. When they allow xAuth, you don't need the step with the pin anymore. xAuth as Twitter defines it is a subset of Twitter's oAuth.
See using xAuth at dev.twitter.com

How do I get the Twitter API to respect the callback parameter with OAuth?

I'm working on an iPhone app that ideally uses OAuth to communicate with Twitter. I know a lot of people are doing the OAuth workflow inside of their apps using a UIWebView, but I don't agree with that and am going with the Pownce approach.
The problem is, Twitter has this whole scheme for working with desktop apps, using a pin number. When I register my app with Twitter, they have a web form asking me if I'm a desktop or web client. If I choose desktop client, when I try to have the user authorize, I can set the oauth_callback parameter but Twitter will ignore it after authorization and show a pin number. If, on twitter's form, I specify that I'm a web client, it requires me to enter a URL to redirect to after authorization. And, since I'm using an iPhone app-specific url scheme, their web form fails on validation as it only seems to accepts URLs conforming to the HTTP protocol.
So, it seems like I'm stuck - I can't say "desktop" because I don't want to bother with a pin, and I can't say "web" or I can't use an iPhone app URL. Any solution to this?
From your question:
I know a lot of people are doing the OAuth workflow inside of their apps using a UIWebView, but I don't agree with that and am going with the Pownce approach.
The Pownce article suggests that quitting your application and opening Mobile Safari to perform the authentication step is problematic, and that they started receiving bad reviews from users for doing it that way. They also experienced a failure rate of around 40%.
Pownce's solution is to use a UIWebView within your application instead, so I have a feeling you may have misinterpreted their recommendations. That being said, they do label this as a "naive" solution and go on to suggest a bunch of theoretical "ideal" solutions.
Another point you might not realise is that desktop applications (using the "out of band" / pin number method) and web applications need to open the Twitter site in either an embedded or external browser.
So you've got two choices on the iPhone:
Open up twitter.com in a UIWebView, specifying no oauth_callback parameter or oauth_callback=oob to start the pin-based out-of-band flow. The user then needs to copy the pin using the iPhone's copy-paste functionality, manually close the UIWebView, and paste the pin into your application. The pin can then be used converted to an access token.
Do it how everyone else is doing it (UIWebView + custom-uri://foo.bar in the callback parameter).
For obvious reasons, the first option is pretty crap and really only useful on platforms where Twitter is unable to redirect to a custom URI.
A simple solution may be to create an HTTP page that always sends a 301 redirect to your custom URL scheme and then provide that HTTP URL to the twitter web API.
Aside from that, Nathan's answer is very complete.
Here's how I do it: tell Twitter you're a web app, and make up any old HTTP:// URL to satisfy Twitter during registration of your oauth client.
Then in your app, pass the URL you want to in the callback parameter. Twitter (in my experience) uses the one you give it.
You could use an intermediate website for the authentication. Your app creates a unique id (hardware based?) and stores it. It then records it has sent the user for authentication and sends the unique id to your website. It then redirects the user to your website. Your website then sends the user to Twitter using oAuth. The user returns to your website and you mark the unique id as authenticated and store the authentication information. The user restarts the app on the iPhone, it reads it has sent the user for authentication and contacts your website with the unique id - and reads in the authentication information.
Long winded and needs another website, but it should work.