Estoy usando angularjs@v1.3
para hacer un request a la api de slack
. Según me dice Slack files types necesito agregar el Authentication
en el header. Hago el request desde postman
y me devuelve el archivo que necesito.
GET /files-pri/... HTTP/1.1
Host: files.slack.com
Authorization: Bearer A_VALID_TOKEN
Cache-Control: no-cache
Postman-Token: POSTMAN_TOKEN
Ahora, haciendo esto desde angular
me devuelve XMLHttpRequest cannot load. Response for preflight is invalid (redirect)
.
$http(
method: 'GET',
url: url_private_download,
headers: {
Authorization: 'Bearer ' + token
}
});
No estoy seguro qué estoy haciendo mal y por qué me devuelve este error, he leído algunas preguntas similares de SO en inglés pero no me queda claro.
Actualización: Al final parece ser un problema con OPTIONS
, según entiendo de esto, angular
(o el navegador, no estoy seguro) solo evita el OPTIONS
si Content-Type=text/plain
. ahora, el problema es que solo lo puedo hacer sin el Authorization
.
¿Cómo agrego el Authorization
evitando el preflight
?
Request actual, necesita el Auth:
$http(
method: 'GET',
url: url_private_download,
headers: {
'Content-Type': 'text/plain',
}
});