I am using [email protected] to make a request to the api of slack . According to Slack files types I need to add the Authentication in the header. I make the request from postman and it returns the file I need.
GET /files-pri/... HTTP/1.1
Host: files.slack.com
Authorization: Bearer A_VALID_TOKEN
Cache-Control: no-cache
Postman-Token: POSTMAN_TOKEN
Now, doing this from angular returns XMLHttpRequest cannot load. Response for preflight is invalid (redirect) .
$http(
method: 'GET',
url: url_private_download,
headers: {
Authorization: 'Bearer ' + token
}
});
I'm not sure what I'm doing wrong and why I get this error back, I've read some similar SO questions in English but it's not clear to me.
Update: In the end it seems to be a problem with OPTIONS , as I understand this , angular (or the browser, I'm not sure) just avoid OPTIONS if Content-Type=text/plain . Now, the problem is that I can only do it without the Authorization .
How do I add Authorization while avoiding preflight ?
Current request, need the Auth:
$http(
method: 'GET',
url: url_private_download,
headers: {
'Content-Type': 'text/plain',
}
});