I am trying to write HTTP post request in AngularJS.
Sending POST request to https://api.att.com/oauth/token
.
Following is the code snippet:
$scope.getToken = function () {
/*alert('in get token');*/
if($http({
method:'POST',
url:'https://api.att.com/oauth/token',
headers:{
'Content-Type':'application/x-www-form-urlencoded',
'Accept':'application/json'
},
params: {
'client_id':'myclientid',
'client_secret':'mysecret',
'grant_type':'client_credentials',
'scope':'SPEECH'
}
}
Error in Chrome:
XMLHttpRequest cannot load https://api.att.com/oauth/token?client_id=d3m1zlqukeyjctt5jj69jicwx4hxlpz9&…zzwjdrvf3cugiiaycxbujqkwjfze782&grant_type=client_credentials&scope=SPEECH. Origin http://localhost:8383 is not allowed by Access-Control-Allow-Origin.
Works fine with a temporary workaround: chrome.exe --disable-web-security .
Is there any other way in client side to solve this problem because I don't have any control on the server side?