Twitter XML Errors Handled Badly #266

Closed
opened 2013-09-07 00:55:30 -07:00 by fletom · 4 comments
fletom commented 2013-09-07 00:55:30 -07:00 (Migrated from github.com)

When a pair of intermediary OAuth tokens expire before you use them (or if you try to reuse them) Twitter spits out a weird XML error. Twython handles this very ungracefully and doesn't raise an error of any kind. Instead if gives us a dictionary with <?xml version as its only key.

>>> twitter.get_authorized_tokens(request.GET['oauth_verifier'])
{u'<?xml version': u'"1.0" encoding="UTF-8"?>\n<hash>\n  <error>Invalid / expired Token</error>\n  <request>/oauth/access_token?oauth_verifier=[redacted]</request>\n</hash>\n'}
When a pair of intermediary OAuth tokens expire before you use them (or if you try to reuse them) Twitter spits out a weird XML error. Twython handles this very ungracefully and doesn't raise an error of any kind. Instead if gives us a dictionary with `<?xml version` as its only key. ``` >>> twitter.get_authorized_tokens(request.GET['oauth_verifier']) {u'<?xml version': u'"1.0" encoding="UTF-8"?>\n<hash>\n <error>Invalid / expired Token</error>\n <request>/oauth/access_token?oauth_verifier=[redacted]</request>\n</hash>\n'} ```
michaelhelmick commented 2013-09-25 13:23:28 -07:00 (Migrated from github.com)

Hm, Twitter seems to be returning a JSON response but not valid JSON. :( I'll try and find a work around for this!

Hm, Twitter seems to be returning a JSON response but not valid JSON. :( I'll try and find a work around for this!
fletom commented 2013-09-25 23:13:45 -07:00 (Migrated from github.com)

Thanks for looking into it! Much appreciated.

Thanks for looking into it! Much appreciated.
michaelhelmick commented 2013-10-25 11:46:16 -07:00 (Migrated from github.com)

Sorry I haven't got around to fixing it. I will try within the next couple weeks. Just have been really overhauled lately!

Sorry I haven't got around to fixing it. I will try within the next couple weeks. Just have been really overhauled lately!
michaelhelmick commented 2013-10-26 16:05:12 -07:00 (Migrated from github.com)

@fletom Manage to find some time to fix this up for you. Will be available in the next version of Twython! Again, sorry for taking so long

@fletom Manage to find some time to fix this up for you. Will be available in the next version of Twython! Again, sorry for taking so long
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: code/twython#266
No description provided.