LibTwitter(C++) - How to get oauth pin


#1

I am using LibTwitter-Core and LibTwitter c++ libraries. It tries to find PIN value in "code-desc\"><code> </code> attribute.

But, my response HTML doesnt contain this <code> tag. With bit of research, I also found that some HTML replaces this code as “oauth_pin” or “oauth_verifier”. But, I dont find any of those tags in my response HTML.

TwitterRequest* auth_tr = new TwitterRequest( this, auth_URL );
auth_tr->add_POST_parameter( OAuthConsts::TOKEN_KEY, auth_page_parser.get_token() ); 
auth_tr->add_POST_parameter( OAuthConsts::AUTHENTICITY_TOKEN_KEY, auth_page_parser.get_auth_token() ); 
auth_tr->add_POST_parameter( OAuthConsts::SESSIONUSERNAME_KEY, user );
auth_tr->add_POST_parameter( OAuthConsts::SESSIONPASSWORD_KEY, password );

/* Sends the form, as if the user clicked on "Allow Application" */
auth_tr->send();
std::string pin_page = auth_tr->get_response_data(); //This is what I mean by Response HTML
PIN_Page_Parser pin_page_parser;
/* Now, a PIN is displayed somewhere on HTML page. Go find it ! */
if ( pin_page_parser.parse_page( pin_page ) ) { // Here's where it tries to find <code> tag

But, the HTML doesnt contain code or oauth_pin or oauth_verifier. May I know what am I missing here


#2

You should not try to parse the PIN out of the OAuth response page, as this violates Twitters Developer Policy/TOS.


#3

Why would you want to automate this? There’s a very good reason that we get users to individually authorise apps to have access to their accounts.