views:

223

answers:

4

Hello,

I can't get Oauth to work with Twitter. I have tried the following (all result in the same 401 error):

  1. jTwitter (using the default OauthSignpostClient)
  2. jTwitter using the commonshttp library (CommonsOauthProvider) instead of the "DefaultOauthProvider"
  3. jTwitter using the OauthScribeClient (instead of the OauthSignpostClient)
  4. oauth-signpost (by itself... no jTwitter)
  5. Twitter4J
  6. http://code.google.com/p/agirardello/
  7. http://dev.bostone.us/2009/07/16/android-oauth-twitter-updates/
  8. http://github.com/kaeppler/signpost-examples/blob/master/OAuthTwitterExample/src/TwitterMain.java

I've tried my own implementation and copy/pasted the sample code from each of the sites, and nothing seems to work. I'm also 100% sure I also downloaded and included any dependencies (where needed).

Here's the interesting part. Using jTwitter and the oauth-signpost library, I can initiate a connection to Twitter, open a browser window for the user, have them log-in and generate a PIN for my app. When the app goes to post a status update however, (using the pin, and the stored access token and token secret), the 401 error pops up. All other things I've tried won't even let me open a browser window and ask the user to generate a PIN (they die with the 401 error on the request for the "request token").

Please help. Thanks

A: 

I don't know if it will help you much with Android, but this post on Twitter OAuth by Chris Shiflett just came up on my interwebs.

Adriano Varoli Piazza
A: 

First of all for OAuth you need to register your application with twitter I am assuming you have registered it. Now in case of desktop and mobile application you need request twitter for custom callback URL, as default callback url just works only for web apps. Once twitter approves requested call back URL , it will work .

But there is workaround, rather than OAuth request twitter for xAuth by submitting details of your applications. Then if twitter approves it , you can uses xAuth which works almost similar to OAuth.

Kodeshpa
Thanks for replying. Yes, I have already registered my app with Twitter. I also think I understand what/how to use the call back URL, but you can choose not to use that technique. You can instead use the "out-of-band" technique, which requires the user to type in a PIN number that Twitter gives him/her. This PIN, along with 2 access tokens, allows your app to post to his/her account. I would like to do this. Please note, I have also tried using the call back method (there is a slick way of doing this on an Android device outlined in one of my links), but that too produced the same 401 error.
borg17of20
A: 

Make sure your application had read&write access when you created it....

viv
A: 

Had the same problem as yours and I solved it another implementation using this. It still uses the signpost libraries

kim