jQuery $.ajax call to GitHub Oauth API return an unidentified error -
first of code:
var requestauthuri = 'https://github.com/login/oauth/access_token'; var ajaxargs = { type : 'post', url : requestauthuri, headers : { 'accept' : 'application/json' }, data : { 'client_id' : this.args['client_id'], 'client_secret' : this.args['client_secret'], 'code' : queryvars['code'] }, datatype : 'json', error : function( jqxhr, textstatus, errorthrown ) { console.log(errorthrown); alert( textstatus + ' : ' + errorthrown ); } }; console.log(ajaxargs); $.ajax( ajaxargs ).done( function( response ) { console.log( response ); });
these server reply headers:
http/1.1 200 ok server: github.com date: mon, 01 jul 2013 08:42:09 gmt content-type: application/json; charset=utf-8 transfer-encoding: chunked connection: keep-alive status: 200 ok cache-control: private, max-age=0, must-revalidate strict-transport-security: max-age=2592000 x-frame-options: deny set-cookie: logged_in=no; domain=.github.com; path=/; expires=fri, 01-jul-2033 08:42:09 gmt; httponly x-runtime: 18 etag: "c4d5365a37fa466698cb5dc6e66f61e3" vary: accept-encoding content-encoding: gzip
and these client headers:
post /login/oauth/access_token http/1.1 host: github.com user-agent: mozilla/5.0 (macintosh; intel mac os x 10.7; rv:22.0) gecko/20100101 firefox/22.0 accept: application/json accept-language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3 accept-encoding: gzip, deflate content-type: application/x-www-form-urlencoded; charset=utf-8 referer: http://site.it/app/?code=xxxxxxxxxxxx content-length: 111 origin: http://site.it connection: keep-alive pragma: no-cache cache-control: no-cache
the problem body content empty, unindentified (empty errorthrown) error triggered $.ajax , i'm struggling figuring out why.
what i've allready tried:
- changing json xml , text datatype
- sending data
application/json
instead ofapplication/x-www-form-urlencoded
- set crossdomain true
am out of luck?! :)
make sure queryvars['code'] holds correct code given github. then, try text/plain response instead, , skip accept-header, see if response.
the error thrown basicly tells you, you've got malformed json-response server. try receive basic reply @ first, move on in json-format.
Comments
Post a Comment