5

Essentially the same problem as this question but looking for a solution in Python. How to work around Twitter OAuth?

Ideally, I dont want to have to go through the hoops of setting up a user/login interface and backend since the work I'm doing is for internal purposes.

I would also like to bypass the part where I need to re-direct the user to Twitter for authorization.

Thanks

Community
  • 1
  • 1
super9
  • 29,181
  • 39
  • 119
  • 172

5 Answers5

3

You'll want to use Twitter's OOB flow. This is explained nicely in this answer

Twitter API - OOB Flow

Community
  • 1
  • 1
JohnD
  • 3,884
  • 1
  • 28
  • 40
  • 1
    Ideally, I would like the process to have zero interaction involving the user. This flow still requires the input of a PIN if Im not mistaken. – super9 May 09 '11 at 02:26
  • 3
    How do you expect to get access to an account without it being authenticated by the user? – Acorn May 09 '11 at 03:06
  • 1
    I want a one-way authentication flow without any input from the user. I never said anything about not being authenticated by the user. – super9 May 10 '11 at 04:42
3

So, reading between the lines a little, you have a twitter account and a password because this is internal, so you don't want to go with an auth process that requires a user to interact with it?

The idea behind OAuth is that you don't ever find out what the user's password is; I agree that if I'm right about what you are trying to do that it isn't the right thing. The OOB Flow suggested by JohnD has the same problem.

If you do have an account/password, then you can work with submissions to the website directly, using the login form and the tweet form. Unfortunately this means you don't have access to the API (they nuked basic authentication via the API last year) -- depending on what you're trying to do that may or may not be a problem.

Edit:

Use OAuth and remember the token. It never expires, according to the twitter API docs, and since you presumably have some limited number of accounts that you care about, you can just jump through the OAuth hoops once for each account and you're done until you need another account. You can even do the whole thing programmatically given the username and password, assuming they don't stick a captcha in there at some point. But I suspect your best bet is to just use OAuth and store the tokens.

Dave Orr
  • 1,082
  • 1
  • 9
  • 18
  • 1
    Yes thats correct. Basic auth would have worked perfectly fine for me but like you said its been deprecated. The non-authenticated data that is exposed in the API do not have all the info. that I need. – super9 May 10 '11 at 04:46
  • @Nai I think you're screwed, then. You can use the public web forms, or you can use something like OAuth. Note, however, that you only have to jump through the OAuth hoop once per account, since the tokens never expire, so you can just cache the tokens. I'll update my response to include that. – Dave Orr May 10 '11 at 05:45
1

I just found this bash script that works, tested personally, just change --ssl to --sslv3.

It's based on a simpler auth method used on mobile.twitter.com, you can use the same principle to deal with it using urllib2 and re modules.


Otherwise you can consider to lean against a site like http://www.supertweet.net/

SuperTweet.net provides a safe mechanism to use Basic Authentication with the Twitter API in your scripts and other Twitter apps. Simply Sign-up via Twitter to authorize the MyAuth API Proxy SuperTweet.net Application and then assign a password of your choosing (not your real Twitter password) that your applications can use with the http://api.supertweet.net API.

edit: I see now this site was cited in an article linked in an answer of How to work around Twitter OAuth?, if you already read about it ignore this part.

Community
  • 1
  • 1
neurino
  • 11,500
  • 2
  • 40
  • 63
1

If you're using a desktop or mobile application, then you can use xAuth. From the user perspective it's the same as basic auth for getting the original OAuth credentials, and there's no going to external pages. Note you have to be approved by the Twitter API team to get xAuth access.

onteria_
  • 68,181
  • 7
  • 71
  • 64
0

You might consider looking at Mechanize. It automates browser activity.

So you could give your username/password to your script. Then the script should pass on those credentials to http://twitter.com/#!/login.

conventionally, if you manually login from that webpage, the response will be another page based on whether the credentials you used were correct.

Same thing here: Based on whether the credentials are correct, the response is another page.

You can then check whether the response is a "login failed" page or a "login passed" page, and do what you need to do from there.

Hope this helps

inspectorG4dget
  • 110,290
  • 27
  • 149
  • 241