Javascript error on oauth/authorize


#1

I’m just writing a client app (win/c#) that will allow the user to tweet a message & photo. I’m using spring.net framework’s functions for oauth handling, and the webbrowser control to show the web pages, and it all works almost great. The almost part is that when the browser navigates to https://api.twitter.com/oauth/authorize?oauth_token=, it throws up a javascript error:

Line: 177
Char: 5
Error: Unable to get value of the property 'contains': object is null or undefined.
Code: 0

Do you want to continue running scripts.

Either yes or no doesn’t matter, I can still sign in and authorize the app, but it’s very annoying. Looking at the html that was sent to the browser, the offending function appears to be:

function($) {
$(‘a’).each(function (i, link) {

if (link.classList.contains('register')) return;

link.target = "_blank";

});
});

And, given that not all of the tags have classes, I’m guessing that is the cause for this. Of course, the real cause may be that the browser engine used by c# is really IE (shudder), but I don’t have much choice in that department.

Has anyone else seen this, and if it is a problem with the page being sent down, is there anything I can do to fix it, short of monkey-patching the html as it arrives?


#2

You should really be opening this sequence in a dedicated web browser – we don’t explicitly support embedded web views – you definitely should not modify the HTML, as that would be seen as tampering with the auth process.


#3

This is going on a self-serve kiosk, so giving the user an open browser is a non-starter - either it works in a controlled environment or it doesn’t go in the app. Why not just fix the js so it checks for undefined? It wouldn’t hurt anything to change the code on the page:

function($) { $('a').each(function (i, link) {
if ((typeof link.classList != 'undefined') && (link.classList.contains('register'))) return;

link.target = "_blank";

});
});

I’ll mention again that the auth process works, it’s just the html being sent down has a bug that this particular rendering engine is sensitive to.


#4

Apologies, that JavaScript should only have been served to IE10 OAuth broker user agents. I’ll roll a fix.


#5

That would be great - thanks!


#6

I’m getting the same error only on IE 9. The line “link.classList.contains(‘register’)” works fine on Chrome and Firefox.
Is there any fix for this issue?