I'm trying to get a token from an API. My cURL command seems to work fine in my terminal, can't seem to get it using $http though.
Here's my cURL:
curl --data "grant_type=authorization_code&client_id=CLIENT_ID&client_secret=SECRET_KEY&redirect_uri=http://localhost:9999&code=AUTH_CODE" https://www.twitchalerts.com/api/v1.0/token
and
curl --data "access_token=ACCESS_TOKEN&name=Kennan&identifier=IDENTIFIER&amount=50¤cy=USD&message=TESTTESTETSTS" https://www.twitchalerts.com/api/v1.0/donations
Currently I'm accessing it like this:
$http.get('https://www.twitchalerts.com/api/v1.0/token?grant_type=authorization_code&client_id=CLIENT_ID&client_secret=SECRET_KEY&redirect_uri=http://localhost:9999&code=' + AUTH_CODE)
.success(function(data) {
console.log(data)
})
.error(function(data) {
alert(data);
console.log('Error: ' + data);
});
It's giving me a 404 though when using the code above. and console error like this:
XMLHttpRequest cannot load https://www.twitchalerts.com/api/v1.0/token?grant_type=authorization_code&c…ct_uri=http://localhost:9999&code=RhWKTP0GACyS6VkfSpVaOlrYTWmKyAKLSwJg2Ynq. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9999' is therefore not allowed access. The response had HTTP status code 404.
I'm expecting a JSON response. Something like this:
{access_token: 'loXk8FTOFwKfrLP3bGCnJldBxuGX03a03iQdxR8A',token_type:'Bearer',refresh_token: 'IXCGDha46Q4eHBKrijmAqUwScbsMSuBy9IopXp80'}