zohar
zohar

Reputation: 2378

How to extract PIN/verifier value from Twitter authorize url in python

I try to find what is the best way to extract the PIN value from the https://dev.twitter.com/docs/api/1/get/oauth/authorize response in python. I know that this is not the best practice and I need to use callback url option but I am doing a POC for idea I have and I try to save some time.

Upvotes: 0

Views: 490

Answers (1)

Jon Nylander
Jon Nylander

Reputation: 8963

You can screen scrape it if you do the authorization in a webview that you control. However, the whole idea, as jterrace mentioned in a comment above, is that a user has to copy and paste it into your application.

Otherwise you are out of options (for good reasons), and you are much better of with a real callback that gets the oauth_verifier (which is in effect the PIN) sent to it. That way you can store and use the oauth_verifier to get an access_token.

I think however that Twitter does not strictly follow the OAuth1.0a specification that introduced the oauth_verifier. So you could just open an authorization window for your request token, wait a minute and then check if the request token has been authorized by the user. You do this by trying to exchange it for an access token. Correct me if I am wrong though.

Upvotes: 1

Related Questions