Hi everyone, new member here on the forum!
I’m working on a small test with the API, but can’t make it work properly by using my on AJAX code authorize. The piece below:
var base_url = "https://api.twitch.tv/kraken/";
var params = {
response_type: 'token',
client_id: [My client Id],
redirect_uri: 'http://localhost',
scope: 'user_read'
};
var url = base_url +"oauth2/authorize?" + $.param(params);
$.ajax({
url: url,
dataType: 'jsonp',
type: 'post',
contentType: 'application/vnd.twitchtv.v2+json'
})
.done(function (msg){
log( "Data: "+JSON.stringify(msg));
})
.fail(function (msg ){
log( "Error: "+JSON.stringify(msg));
});
Returns this on Chrome:
Uncaught SyntaxError: Unexpected token <
on
authenticate?_=1418417804931&action=authorize&callback=jQuery111104965348285622895_1418417804930&cl…:1
And my callback gives me:
[LOG] Error: {"readyState":4,"status":200,"statusText":"success"}
Using the SDK does not render the same problem, in fact I’m able to redirect the page to the login section. However, my app will not run on a browser, so I would like to use my own custom user interface. Still, even making my code as similar as possible with the API, it didn’t work.
Does anyone had a similar experience?
Best Regards!
Adriel