Passing variable to “authorization: bearer” header with Curl and Bash
I've been trying to make this work for a while now, and I just can't see why it's not working. It's just a simple script that's supposed to return either 200 (if it works) or 400 (if it doesn't). The trouble seems to come when I use variables to substitute values in Curl, example of a working curl:
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H
**'authorization: bearer iUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfao'**
--header 'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
This works as expected and returns 200. When I replace the authorization bearer section in the following way I get a 400:
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H "authorization: bearer $TOKEN" --header
'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
I tried literally everything. Using the variable as "${TOKEN}", doing "'authorization: bearer $TOKEN'", even something similar to "'"'"'$TOKEN'"'"'". I don't know what else to try. When I remove the silent curl option I see the following error:
400ODY></HTML>ror 400. The request is badly formed.</p>rset=us-ascii"></HEAD>trict.dtd">
I'm lost to why it works with plain text and not variables. Any ideas?
Edit:
Added verbose for both:
> GET /REDACTED-URL HTTP/1.1
> Host: hostname:44301
> User-Agent: curl/7.50.3
> Accept: */*
> authorization: bearer eyJ0eXA700JKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSIsImtpZCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSJ9.eyJpc3MiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMiLCJhdWQiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMvcmVzb3VyY2VzIiwiZXhwIjoxNTUyNDI5MTA1LCJuYmYiOjE1NTI0MjU1MDUsImNsaWVudF9pZCI6Ik1FUkNBRE9MSUJSRUlWUiIsImNsaWVudF9NYXJjYSI6IjEiLCJjbGllbnRfVXN1YUNvZGkiOiJEQk8iLCJjbGllbnRfVmFsaWRhRXN0YWRvQ3VlbnRhIjoiMCIsImNsaWVudF9FbnRpZGFkIjoiMzAiLCJzY29wZSI6IlByZXBhZ2FBcGkifQ.kkCGp3EJ7VkvR75Zt0MV5VRmNVf-jP5dcb7GaZF6nI5KGNUxfx_linht3nUUX4Hw55ZKhfkiUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfaofoBnK0EWgqsQxcxPNre2PkvxWV-x6AzPl_uVWml1Wo2bjAi37kVklYmjkbBIWe8EcyF90MMR28xcipIo2ULj5HgOizhvokPg1qDEiYetTU2MYJ1fFRVgJ5v7KF0mpUk7zBl9dvFeGT3MPfTN9EED4biqE-zRaC0r8DK7lr1PScfVHqs09sI89PXTN9Nm2lOT6c43CsUy-YhylhjJr6AfIARcFv1o0-gy0nKnWxSBYnt8NgK7rZCfpjFDUfmaYL5IXqirob98L0cWfvnV3iL6R73dNciayRDy6PqZG0sHWhKkggBIOhRqh-7VsY99qCqG76Beih-UqWPcWO_H8-4zvYDslsXMj8ff1Nk76h9pxuy-qAkRapNVAbBojf41JFVVaONqgPCH9Jszq7cpFbX6vbVq18p6hOhDb4BhuTDkT6tB30RXQWaSPqRbRs2h7VYIcuxok6wbrBzGA32hBHiSVSQs0PdheJlVy1EcHy27MJuIj_Vs6bsiq0a4GY-scs4A-68fvzsERfsLLINDrS4C9zY1f6RwfEkDsWlQ1ouBIk
> content-type: application/json
> requestid: '999993245235232323523523523535'
>
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Server: Microsoft-IIS/10.0
< requestid: '999993245235232323523523523535'
< CorrelationId: 3859af6f-4c8f-438c-bcfe-37ab6ecc0d6b
< RequestId: 9999af6f-4c8f-438c-bcfe-37ab6ecc0d6b
< X-Powered-By: ASP.NET
< Date: Tue, 12 Mar 2019 22:10:39 GMT
< Content-Length: 992
<
{ [992 bytes data]
This works ^
> GET /REDACTED-URL HTTP/1.1
> Host: hostname:44301
> User-Agent: curl/7.50.3
> Accept: */*
> authorization: bearer eyJ0eXA700JKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSIsImtpZCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSJ9.eyJpc3MiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMiLCJhdWQiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMvcmVzb3VyY2VzIiwiZXhwIjoxNTUyNDI5MTA1LCJuYmYiOjE1NTI0MjU1MDUsImNsaWVudF9pZCI6Ik1FUkNBRE9MSUJSRUlWUiIsImNsaWVudF9NYXJjYSI6IjEiLCJjbGllbnRfVXN1YUNvZGkiOiJEQk8iLCJjbGllbnRfVmFsaWRhRXN0YWRvQ3VlbnRhIjoiMCIsImNsaWVudF9FbnRpZGFkIjoiMzAiLCJzY29wZSI6IlByZXBhZ2FBcGkifQ.kkCGp3EJ7VkvR75Zt0MV5VRmNVf-jP5dcb7GaZF6nI5KGNUxfx_linht3nUUX4Hw55ZKhfkiUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfaofoBnK0EWgqsQxcxPNre2PkvxWV-x6AzPl_uVWml1Wo2bjAi37kVklYmjkbBIWe8EcyF90MMR28xcipIo2ULj5HgOizhvokPg1qDEiYetTU2MYJ1fFRVgJ5v7KF0mpUk7zBl9dvFeGT3MPfTN9EED4biqE-zRaC0r8DK7lr1PScfVHqs09sI89PXTN9Nm2lOT6c43CsUy-YhylhjJr6AfIARcFv1o0-gy0nKnWxSBYnt8NgK7rZCfpjFDUfmaYL5IXqirob98L0cWfvnV3iL6R73dNciayRDy6PqZG0sHWhKkggBIOhRqh-7VsY99qCqG76Beih-UqWPcWO_H8-4zvYDslsXMj8ff1Nk76h9pxuy-qAkRapNVAbBojf41JFVVaONqgPCH9Jszq7cpFbX6vbVq18p6hOhDb4BhuTDkT6tB30RXQWaSPqRbRs2h7VYIcuxok6wbrBzGA32hBHiSVSQs0PdheJlVy1EcHy27MJuIj_Vs6bsiq0a4GY-scs4A-68fvzsERfsLLINDrS4C9zY1f6RwfEkDsWlQ1ouBIk
> content-type: application/json
> requestid: '99999324523523534395600'
>
< HTTP/1.1 400 Bad Request
< Content-Type: text/html; charset=us-ascii
< Server: Microsoft-HTTPAPI/2.0
< Date: Tue, 12 Mar 2019 22:11:42 GMT
< Connection: close
< Content-Length: 311
<
{ [311 bytes data]
This doesn't. Same exact headers.
bash curl
New contributor
Rodrigo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I've been trying to make this work for a while now, and I just can't see why it's not working. It's just a simple script that's supposed to return either 200 (if it works) or 400 (if it doesn't). The trouble seems to come when I use variables to substitute values in Curl, example of a working curl:
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H
**'authorization: bearer iUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfao'**
--header 'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
This works as expected and returns 200. When I replace the authorization bearer section in the following way I get a 400:
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H "authorization: bearer $TOKEN" --header
'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
I tried literally everything. Using the variable as "${TOKEN}", doing "'authorization: bearer $TOKEN'", even something similar to "'"'"'$TOKEN'"'"'". I don't know what else to try. When I remove the silent curl option I see the following error:
400ODY></HTML>ror 400. The request is badly formed.</p>rset=us-ascii"></HEAD>trict.dtd">
I'm lost to why it works with plain text and not variables. Any ideas?
Edit:
Added verbose for both:
> GET /REDACTED-URL HTTP/1.1
> Host: hostname:44301
> User-Agent: curl/7.50.3
> Accept: */*
> authorization: bearer eyJ0eXA700JKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSIsImtpZCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSJ9.eyJpc3MiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMiLCJhdWQiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMvcmVzb3VyY2VzIiwiZXhwIjoxNTUyNDI5MTA1LCJuYmYiOjE1NTI0MjU1MDUsImNsaWVudF9pZCI6Ik1FUkNBRE9MSUJSRUlWUiIsImNsaWVudF9NYXJjYSI6IjEiLCJjbGllbnRfVXN1YUNvZGkiOiJEQk8iLCJjbGllbnRfVmFsaWRhRXN0YWRvQ3VlbnRhIjoiMCIsImNsaWVudF9FbnRpZGFkIjoiMzAiLCJzY29wZSI6IlByZXBhZ2FBcGkifQ.kkCGp3EJ7VkvR75Zt0MV5VRmNVf-jP5dcb7GaZF6nI5KGNUxfx_linht3nUUX4Hw55ZKhfkiUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfaofoBnK0EWgqsQxcxPNre2PkvxWV-x6AzPl_uVWml1Wo2bjAi37kVklYmjkbBIWe8EcyF90MMR28xcipIo2ULj5HgOizhvokPg1qDEiYetTU2MYJ1fFRVgJ5v7KF0mpUk7zBl9dvFeGT3MPfTN9EED4biqE-zRaC0r8DK7lr1PScfVHqs09sI89PXTN9Nm2lOT6c43CsUy-YhylhjJr6AfIARcFv1o0-gy0nKnWxSBYnt8NgK7rZCfpjFDUfmaYL5IXqirob98L0cWfvnV3iL6R73dNciayRDy6PqZG0sHWhKkggBIOhRqh-7VsY99qCqG76Beih-UqWPcWO_H8-4zvYDslsXMj8ff1Nk76h9pxuy-qAkRapNVAbBojf41JFVVaONqgPCH9Jszq7cpFbX6vbVq18p6hOhDb4BhuTDkT6tB30RXQWaSPqRbRs2h7VYIcuxok6wbrBzGA32hBHiSVSQs0PdheJlVy1EcHy27MJuIj_Vs6bsiq0a4GY-scs4A-68fvzsERfsLLINDrS4C9zY1f6RwfEkDsWlQ1ouBIk
> content-type: application/json
> requestid: '999993245235232323523523523535'
>
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Server: Microsoft-IIS/10.0
< requestid: '999993245235232323523523523535'
< CorrelationId: 3859af6f-4c8f-438c-bcfe-37ab6ecc0d6b
< RequestId: 9999af6f-4c8f-438c-bcfe-37ab6ecc0d6b
< X-Powered-By: ASP.NET
< Date: Tue, 12 Mar 2019 22:10:39 GMT
< Content-Length: 992
<
{ [992 bytes data]
This works ^
> GET /REDACTED-URL HTTP/1.1
> Host: hostname:44301
> User-Agent: curl/7.50.3
> Accept: */*
> authorization: bearer eyJ0eXA700JKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSIsImtpZCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSJ9.eyJpc3MiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMiLCJhdWQiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMvcmVzb3VyY2VzIiwiZXhwIjoxNTUyNDI5MTA1LCJuYmYiOjE1NTI0MjU1MDUsImNsaWVudF9pZCI6Ik1FUkNBRE9MSUJSRUlWUiIsImNsaWVudF9NYXJjYSI6IjEiLCJjbGllbnRfVXN1YUNvZGkiOiJEQk8iLCJjbGllbnRfVmFsaWRhRXN0YWRvQ3VlbnRhIjoiMCIsImNsaWVudF9FbnRpZGFkIjoiMzAiLCJzY29wZSI6IlByZXBhZ2FBcGkifQ.kkCGp3EJ7VkvR75Zt0MV5VRmNVf-jP5dcb7GaZF6nI5KGNUxfx_linht3nUUX4Hw55ZKhfkiUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfaofoBnK0EWgqsQxcxPNre2PkvxWV-x6AzPl_uVWml1Wo2bjAi37kVklYmjkbBIWe8EcyF90MMR28xcipIo2ULj5HgOizhvokPg1qDEiYetTU2MYJ1fFRVgJ5v7KF0mpUk7zBl9dvFeGT3MPfTN9EED4biqE-zRaC0r8DK7lr1PScfVHqs09sI89PXTN9Nm2lOT6c43CsUy-YhylhjJr6AfIARcFv1o0-gy0nKnWxSBYnt8NgK7rZCfpjFDUfmaYL5IXqirob98L0cWfvnV3iL6R73dNciayRDy6PqZG0sHWhKkggBIOhRqh-7VsY99qCqG76Beih-UqWPcWO_H8-4zvYDslsXMj8ff1Nk76h9pxuy-qAkRapNVAbBojf41JFVVaONqgPCH9Jszq7cpFbX6vbVq18p6hOhDb4BhuTDkT6tB30RXQWaSPqRbRs2h7VYIcuxok6wbrBzGA32hBHiSVSQs0PdheJlVy1EcHy27MJuIj_Vs6bsiq0a4GY-scs4A-68fvzsERfsLLINDrS4C9zY1f6RwfEkDsWlQ1ouBIk
> content-type: application/json
> requestid: '99999324523523534395600'
>
< HTTP/1.1 400 Bad Request
< Content-Type: text/html; charset=us-ascii
< Server: Microsoft-HTTPAPI/2.0
< Date: Tue, 12 Mar 2019 22:11:42 GMT
< Connection: close
< Content-Length: 311
<
{ [311 bytes data]
This doesn't. Same exact headers.
bash curl
New contributor
Rodrigo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
How did you setTOKEN? If you useset -xand then run thecurlcommand, what does the shell show as the argument to-H?
– ilkkachu
2 hours ago
$TOKEN was set just plainly on top of the script as: TOKEN="iUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfao"
– Rodrigo
2 hours ago
well yeah, it looks like it should work, so that's why I asked about whatset -xshows. You are sure that you used double quotes around the"authorization: bearer $TOKEN"as you have posted here, and not single quotes, right?
– ilkkachu
1 hour ago
Absolutely sure. I tried all combinations anyway, I updated the post showing that the headers are being passed identically as text, yet when I use the variable it fails.
– Rodrigo
1 hour ago
add a comment |
I've been trying to make this work for a while now, and I just can't see why it's not working. It's just a simple script that's supposed to return either 200 (if it works) or 400 (if it doesn't). The trouble seems to come when I use variables to substitute values in Curl, example of a working curl:
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H
**'authorization: bearer iUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfao'**
--header 'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
This works as expected and returns 200. When I replace the authorization bearer section in the following way I get a 400:
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H "authorization: bearer $TOKEN" --header
'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
I tried literally everything. Using the variable as "${TOKEN}", doing "'authorization: bearer $TOKEN'", even something similar to "'"'"'$TOKEN'"'"'". I don't know what else to try. When I remove the silent curl option I see the following error:
400ODY></HTML>ror 400. The request is badly formed.</p>rset=us-ascii"></HEAD>trict.dtd">
I'm lost to why it works with plain text and not variables. Any ideas?
Edit:
Added verbose for both:
> GET /REDACTED-URL HTTP/1.1
> Host: hostname:44301
> User-Agent: curl/7.50.3
> Accept: */*
> authorization: bearer eyJ0eXA700JKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSIsImtpZCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSJ9.eyJpc3MiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMiLCJhdWQiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMvcmVzb3VyY2VzIiwiZXhwIjoxNTUyNDI5MTA1LCJuYmYiOjE1NTI0MjU1MDUsImNsaWVudF9pZCI6Ik1FUkNBRE9MSUJSRUlWUiIsImNsaWVudF9NYXJjYSI6IjEiLCJjbGllbnRfVXN1YUNvZGkiOiJEQk8iLCJjbGllbnRfVmFsaWRhRXN0YWRvQ3VlbnRhIjoiMCIsImNsaWVudF9FbnRpZGFkIjoiMzAiLCJzY29wZSI6IlByZXBhZ2FBcGkifQ.kkCGp3EJ7VkvR75Zt0MV5VRmNVf-jP5dcb7GaZF6nI5KGNUxfx_linht3nUUX4Hw55ZKhfkiUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfaofoBnK0EWgqsQxcxPNre2PkvxWV-x6AzPl_uVWml1Wo2bjAi37kVklYmjkbBIWe8EcyF90MMR28xcipIo2ULj5HgOizhvokPg1qDEiYetTU2MYJ1fFRVgJ5v7KF0mpUk7zBl9dvFeGT3MPfTN9EED4biqE-zRaC0r8DK7lr1PScfVHqs09sI89PXTN9Nm2lOT6c43CsUy-YhylhjJr6AfIARcFv1o0-gy0nKnWxSBYnt8NgK7rZCfpjFDUfmaYL5IXqirob98L0cWfvnV3iL6R73dNciayRDy6PqZG0sHWhKkggBIOhRqh-7VsY99qCqG76Beih-UqWPcWO_H8-4zvYDslsXMj8ff1Nk76h9pxuy-qAkRapNVAbBojf41JFVVaONqgPCH9Jszq7cpFbX6vbVq18p6hOhDb4BhuTDkT6tB30RXQWaSPqRbRs2h7VYIcuxok6wbrBzGA32hBHiSVSQs0PdheJlVy1EcHy27MJuIj_Vs6bsiq0a4GY-scs4A-68fvzsERfsLLINDrS4C9zY1f6RwfEkDsWlQ1ouBIk
> content-type: application/json
> requestid: '999993245235232323523523523535'
>
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Server: Microsoft-IIS/10.0
< requestid: '999993245235232323523523523535'
< CorrelationId: 3859af6f-4c8f-438c-bcfe-37ab6ecc0d6b
< RequestId: 9999af6f-4c8f-438c-bcfe-37ab6ecc0d6b
< X-Powered-By: ASP.NET
< Date: Tue, 12 Mar 2019 22:10:39 GMT
< Content-Length: 992
<
{ [992 bytes data]
This works ^
> GET /REDACTED-URL HTTP/1.1
> Host: hostname:44301
> User-Agent: curl/7.50.3
> Accept: */*
> authorization: bearer eyJ0eXA700JKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSIsImtpZCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSJ9.eyJpc3MiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMiLCJhdWQiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMvcmVzb3VyY2VzIiwiZXhwIjoxNTUyNDI5MTA1LCJuYmYiOjE1NTI0MjU1MDUsImNsaWVudF9pZCI6Ik1FUkNBRE9MSUJSRUlWUiIsImNsaWVudF9NYXJjYSI6IjEiLCJjbGllbnRfVXN1YUNvZGkiOiJEQk8iLCJjbGllbnRfVmFsaWRhRXN0YWRvQ3VlbnRhIjoiMCIsImNsaWVudF9FbnRpZGFkIjoiMzAiLCJzY29wZSI6IlByZXBhZ2FBcGkifQ.kkCGp3EJ7VkvR75Zt0MV5VRmNVf-jP5dcb7GaZF6nI5KGNUxfx_linht3nUUX4Hw55ZKhfkiUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfaofoBnK0EWgqsQxcxPNre2PkvxWV-x6AzPl_uVWml1Wo2bjAi37kVklYmjkbBIWe8EcyF90MMR28xcipIo2ULj5HgOizhvokPg1qDEiYetTU2MYJ1fFRVgJ5v7KF0mpUk7zBl9dvFeGT3MPfTN9EED4biqE-zRaC0r8DK7lr1PScfVHqs09sI89PXTN9Nm2lOT6c43CsUy-YhylhjJr6AfIARcFv1o0-gy0nKnWxSBYnt8NgK7rZCfpjFDUfmaYL5IXqirob98L0cWfvnV3iL6R73dNciayRDy6PqZG0sHWhKkggBIOhRqh-7VsY99qCqG76Beih-UqWPcWO_H8-4zvYDslsXMj8ff1Nk76h9pxuy-qAkRapNVAbBojf41JFVVaONqgPCH9Jszq7cpFbX6vbVq18p6hOhDb4BhuTDkT6tB30RXQWaSPqRbRs2h7VYIcuxok6wbrBzGA32hBHiSVSQs0PdheJlVy1EcHy27MJuIj_Vs6bsiq0a4GY-scs4A-68fvzsERfsLLINDrS4C9zY1f6RwfEkDsWlQ1ouBIk
> content-type: application/json
> requestid: '99999324523523534395600'
>
< HTTP/1.1 400 Bad Request
< Content-Type: text/html; charset=us-ascii
< Server: Microsoft-HTTPAPI/2.0
< Date: Tue, 12 Mar 2019 22:11:42 GMT
< Connection: close
< Content-Length: 311
<
{ [311 bytes data]
This doesn't. Same exact headers.
bash curl
New contributor
Rodrigo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I've been trying to make this work for a while now, and I just can't see why it's not working. It's just a simple script that's supposed to return either 200 (if it works) or 400 (if it doesn't). The trouble seems to come when I use variables to substitute values in Curl, example of a working curl:
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H
**'authorization: bearer iUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfao'**
--header 'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
This works as expected and returns 200. When I replace the authorization bearer section in the following way I get a 400:
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H "authorization: bearer $TOKEN" --header
'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
I tried literally everything. Using the variable as "${TOKEN}", doing "'authorization: bearer $TOKEN'", even something similar to "'"'"'$TOKEN'"'"'". I don't know what else to try. When I remove the silent curl option I see the following error:
400ODY></HTML>ror 400. The request is badly formed.</p>rset=us-ascii"></HEAD>trict.dtd">
I'm lost to why it works with plain text and not variables. Any ideas?
Edit:
Added verbose for both:
> GET /REDACTED-URL HTTP/1.1
> Host: hostname:44301
> User-Agent: curl/7.50.3
> Accept: */*
> authorization: bearer eyJ0eXA700JKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSIsImtpZCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSJ9.eyJpc3MiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMiLCJhdWQiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMvcmVzb3VyY2VzIiwiZXhwIjoxNTUyNDI5MTA1LCJuYmYiOjE1NTI0MjU1MDUsImNsaWVudF9pZCI6Ik1FUkNBRE9MSUJSRUlWUiIsImNsaWVudF9NYXJjYSI6IjEiLCJjbGllbnRfVXN1YUNvZGkiOiJEQk8iLCJjbGllbnRfVmFsaWRhRXN0YWRvQ3VlbnRhIjoiMCIsImNsaWVudF9FbnRpZGFkIjoiMzAiLCJzY29wZSI6IlByZXBhZ2FBcGkifQ.kkCGp3EJ7VkvR75Zt0MV5VRmNVf-jP5dcb7GaZF6nI5KGNUxfx_linht3nUUX4Hw55ZKhfkiUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfaofoBnK0EWgqsQxcxPNre2PkvxWV-x6AzPl_uVWml1Wo2bjAi37kVklYmjkbBIWe8EcyF90MMR28xcipIo2ULj5HgOizhvokPg1qDEiYetTU2MYJ1fFRVgJ5v7KF0mpUk7zBl9dvFeGT3MPfTN9EED4biqE-zRaC0r8DK7lr1PScfVHqs09sI89PXTN9Nm2lOT6c43CsUy-YhylhjJr6AfIARcFv1o0-gy0nKnWxSBYnt8NgK7rZCfpjFDUfmaYL5IXqirob98L0cWfvnV3iL6R73dNciayRDy6PqZG0sHWhKkggBIOhRqh-7VsY99qCqG76Beih-UqWPcWO_H8-4zvYDslsXMj8ff1Nk76h9pxuy-qAkRapNVAbBojf41JFVVaONqgPCH9Jszq7cpFbX6vbVq18p6hOhDb4BhuTDkT6tB30RXQWaSPqRbRs2h7VYIcuxok6wbrBzGA32hBHiSVSQs0PdheJlVy1EcHy27MJuIj_Vs6bsiq0a4GY-scs4A-68fvzsERfsLLINDrS4C9zY1f6RwfEkDsWlQ1ouBIk
> content-type: application/json
> requestid: '999993245235232323523523523535'
>
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Server: Microsoft-IIS/10.0
< requestid: '999993245235232323523523523535'
< CorrelationId: 3859af6f-4c8f-438c-bcfe-37ab6ecc0d6b
< RequestId: 9999af6f-4c8f-438c-bcfe-37ab6ecc0d6b
< X-Powered-By: ASP.NET
< Date: Tue, 12 Mar 2019 22:10:39 GMT
< Content-Length: 992
<
{ [992 bytes data]
This works ^
> GET /REDACTED-URL HTTP/1.1
> Host: hostname:44301
> User-Agent: curl/7.50.3
> Accept: */*
> authorization: bearer eyJ0eXA700JKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSIsImtpZCI6ImF1bkM2QV9MbHFVZGNYV3Z6UzVGOURQUEFTSSJ9.eyJpc3MiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMiLCJhdWQiOiJodHRwczovL0dQLUlEUzo0NDMwMS9HUC5JRFMvcmVzb3VyY2VzIiwiZXhwIjoxNTUyNDI5MTA1LCJuYmYiOjE1NTI0MjU1MDUsImNsaWVudF9pZCI6Ik1FUkNBRE9MSUJSRUlWUiIsImNsaWVudF9NYXJjYSI6IjEiLCJjbGllbnRfVXN1YUNvZGkiOiJEQk8iLCJjbGllbnRfVmFsaWRhRXN0YWRvQ3VlbnRhIjoiMCIsImNsaWVudF9FbnRpZGFkIjoiMzAiLCJzY29wZSI6IlByZXBhZ2FBcGkifQ.kkCGp3EJ7VkvR75Zt0MV5VRmNVf-jP5dcb7GaZF6nI5KGNUxfx_linht3nUUX4Hw55ZKhfkiUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfaofoBnK0EWgqsQxcxPNre2PkvxWV-x6AzPl_uVWml1Wo2bjAi37kVklYmjkbBIWe8EcyF90MMR28xcipIo2ULj5HgOizhvokPg1qDEiYetTU2MYJ1fFRVgJ5v7KF0mpUk7zBl9dvFeGT3MPfTN9EED4biqE-zRaC0r8DK7lr1PScfVHqs09sI89PXTN9Nm2lOT6c43CsUy-YhylhjJr6AfIARcFv1o0-gy0nKnWxSBYnt8NgK7rZCfpjFDUfmaYL5IXqirob98L0cWfvnV3iL6R73dNciayRDy6PqZG0sHWhKkggBIOhRqh-7VsY99qCqG76Beih-UqWPcWO_H8-4zvYDslsXMj8ff1Nk76h9pxuy-qAkRapNVAbBojf41JFVVaONqgPCH9Jszq7cpFbX6vbVq18p6hOhDb4BhuTDkT6tB30RXQWaSPqRbRs2h7VYIcuxok6wbrBzGA32hBHiSVSQs0PdheJlVy1EcHy27MJuIj_Vs6bsiq0a4GY-scs4A-68fvzsERfsLLINDrS4C9zY1f6RwfEkDsWlQ1ouBIk
> content-type: application/json
> requestid: '99999324523523534395600'
>
< HTTP/1.1 400 Bad Request
< Content-Type: text/html; charset=us-ascii
< Server: Microsoft-HTTPAPI/2.0
< Date: Tue, 12 Mar 2019 22:11:42 GMT
< Connection: close
< Content-Length: 311
<
{ [311 bytes data]
This doesn't. Same exact headers.
bash curl
bash curl
New contributor
Rodrigo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Rodrigo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 1 hour ago
Rodrigo
New contributor
Rodrigo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 hours ago
RodrigoRodrigo
42
42
New contributor
Rodrigo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Rodrigo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Rodrigo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
How did you setTOKEN? If you useset -xand then run thecurlcommand, what does the shell show as the argument to-H?
– ilkkachu
2 hours ago
$TOKEN was set just plainly on top of the script as: TOKEN="iUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfao"
– Rodrigo
2 hours ago
well yeah, it looks like it should work, so that's why I asked about whatset -xshows. You are sure that you used double quotes around the"authorization: bearer $TOKEN"as you have posted here, and not single quotes, right?
– ilkkachu
1 hour ago
Absolutely sure. I tried all combinations anyway, I updated the post showing that the headers are being passed identically as text, yet when I use the variable it fails.
– Rodrigo
1 hour ago
add a comment |
How did you setTOKEN? If you useset -xand then run thecurlcommand, what does the shell show as the argument to-H?
– ilkkachu
2 hours ago
$TOKEN was set just plainly on top of the script as: TOKEN="iUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfao"
– Rodrigo
2 hours ago
well yeah, it looks like it should work, so that's why I asked about whatset -xshows. You are sure that you used double quotes around the"authorization: bearer $TOKEN"as you have posted here, and not single quotes, right?
– ilkkachu
1 hour ago
Absolutely sure. I tried all combinations anyway, I updated the post showing that the headers are being passed identically as text, yet when I use the variable it fails.
– Rodrigo
1 hour ago
How did you set
TOKEN? If you use set -x and then run the curl command, what does the shell show as the argument to -H?– ilkkachu
2 hours ago
How did you set
TOKEN? If you use set -x and then run the curl command, what does the shell show as the argument to -H?– ilkkachu
2 hours ago
$TOKEN was set just plainly on top of the script as: TOKEN="iUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfao"
– Rodrigo
2 hours ago
$TOKEN was set just plainly on top of the script as: TOKEN="iUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfao"
– Rodrigo
2 hours ago
well yeah, it looks like it should work, so that's why I asked about what
set -x shows. You are sure that you used double quotes around the "authorization: bearer $TOKEN" as you have posted here, and not single quotes, right?– ilkkachu
1 hour ago
well yeah, it looks like it should work, so that's why I asked about what
set -x shows. You are sure that you used double quotes around the "authorization: bearer $TOKEN" as you have posted here, and not single quotes, right?– ilkkachu
1 hour ago
Absolutely sure. I tried all combinations anyway, I updated the post showing that the headers are being passed identically as text, yet when I use the variable it fails.
– Rodrigo
1 hour ago
Absolutely sure. I tried all combinations anyway, I updated the post showing that the headers are being passed identically as text, yet when I use the variable it fails.
– Rodrigo
1 hour ago
add a comment |
1 Answer
1
active
oldest
votes
Assuming you set TOKEN as environment variable with export TOKEN=foo you should use ${TOKEN} in your header string.
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H "authorization: bearer ${TOKEN}" --header
'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
Using the --verbose option instead of --silent will print the following header information (excerpt):
> GET / HTTP/2
> Host: url
> User-Agent: curl/7.58.0
> Accept: */*
> authorization: bearer foo
> content-type: application/json
> requestid: '999993122349238343493843958345'
Alternatively -H "authorization: bearer "$TOKEN should work too.
It is also very important to use double quotes, because single quotes will not be parsed.
New contributor
Samuel P. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
With --verbose on I can see both with $TOKEN and the plain text (working one) are giving the exact same authorization: bearer text. Yet one works and the other doesn't.
– Rodrigo
1 hour ago
Have you tried-H "authorization: bearer ${TOKEN}"?
– Samuel P.
1 hour ago
Yes. Same issue. Tried all possible combinations of variable display. Not sure if this is some kind of bug with Curl itself.
– Rodrigo
1 hour ago
Which version of curl are you using (curl --version)?
– Samuel P.
1 hour ago
curl 7.50.3 (i686-pc-cygwin)
– Rodrigo
1 hour ago
|
show 7 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Rodrigo is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f505966%2fpassing-variable-to-authorization-bearer-header-with-curl-and-bash%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Assuming you set TOKEN as environment variable with export TOKEN=foo you should use ${TOKEN} in your header string.
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H "authorization: bearer ${TOKEN}" --header
'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
Using the --verbose option instead of --silent will print the following header information (excerpt):
> GET / HTTP/2
> Host: url
> User-Agent: curl/7.58.0
> Accept: */*
> authorization: bearer foo
> content-type: application/json
> requestid: '999993122349238343493843958345'
Alternatively -H "authorization: bearer "$TOKEN should work too.
It is also very important to use double quotes, because single quotes will not be parsed.
New contributor
Samuel P. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
With --verbose on I can see both with $TOKEN and the plain text (working one) are giving the exact same authorization: bearer text. Yet one works and the other doesn't.
– Rodrigo
1 hour ago
Have you tried-H "authorization: bearer ${TOKEN}"?
– Samuel P.
1 hour ago
Yes. Same issue. Tried all possible combinations of variable display. Not sure if this is some kind of bug with Curl itself.
– Rodrigo
1 hour ago
Which version of curl are you using (curl --version)?
– Samuel P.
1 hour ago
curl 7.50.3 (i686-pc-cygwin)
– Rodrigo
1 hour ago
|
show 7 more comments
Assuming you set TOKEN as environment variable with export TOKEN=foo you should use ${TOKEN} in your header string.
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H "authorization: bearer ${TOKEN}" --header
'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
Using the --verbose option instead of --silent will print the following header information (excerpt):
> GET / HTTP/2
> Host: url
> User-Agent: curl/7.58.0
> Accept: */*
> authorization: bearer foo
> content-type: application/json
> requestid: '999993122349238343493843958345'
Alternatively -H "authorization: bearer "$TOKEN should work too.
It is also very important to use double quotes, because single quotes will not be parsed.
New contributor
Samuel P. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
With --verbose on I can see both with $TOKEN and the plain text (working one) are giving the exact same authorization: bearer text. Yet one works and the other doesn't.
– Rodrigo
1 hour ago
Have you tried-H "authorization: bearer ${TOKEN}"?
– Samuel P.
1 hour ago
Yes. Same issue. Tried all possible combinations of variable display. Not sure if this is some kind of bug with Curl itself.
– Rodrigo
1 hour ago
Which version of curl are you using (curl --version)?
– Samuel P.
1 hour ago
curl 7.50.3 (i686-pc-cygwin)
– Rodrigo
1 hour ago
|
show 7 more comments
Assuming you set TOKEN as environment variable with export TOKEN=foo you should use ${TOKEN} in your header string.
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H "authorization: bearer ${TOKEN}" --header
'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
Using the --verbose option instead of --silent will print the following header information (excerpt):
> GET / HTTP/2
> Host: url
> User-Agent: curl/7.58.0
> Accept: */*
> authorization: bearer foo
> content-type: application/json
> requestid: '999993122349238343493843958345'
Alternatively -H "authorization: bearer "$TOKEN should work too.
It is also very important to use double quotes, because single quotes will not be parsed.
New contributor
Samuel P. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Assuming you set TOKEN as environment variable with export TOKEN=foo you should use ${TOKEN} in your header string.
curl --max-time 10 --write-out '%{http_code}' --silent --output '/dev/null'
--insecure -X GET https://url -H "authorization: bearer ${TOKEN}" --header
'content-type: application/json' --header
"requestid: '999993122349238343493843958345'"
Using the --verbose option instead of --silent will print the following header information (excerpt):
> GET / HTTP/2
> Host: url
> User-Agent: curl/7.58.0
> Accept: */*
> authorization: bearer foo
> content-type: application/json
> requestid: '999993122349238343493843958345'
Alternatively -H "authorization: bearer "$TOKEN should work too.
It is also very important to use double quotes, because single quotes will not be parsed.
New contributor
Samuel P. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 1 hour ago
New contributor
Samuel P. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 2 hours ago
Samuel P.Samuel P.
1267
1267
New contributor
Samuel P. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Samuel P. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Samuel P. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
With --verbose on I can see both with $TOKEN and the plain text (working one) are giving the exact same authorization: bearer text. Yet one works and the other doesn't.
– Rodrigo
1 hour ago
Have you tried-H "authorization: bearer ${TOKEN}"?
– Samuel P.
1 hour ago
Yes. Same issue. Tried all possible combinations of variable display. Not sure if this is some kind of bug with Curl itself.
– Rodrigo
1 hour ago
Which version of curl are you using (curl --version)?
– Samuel P.
1 hour ago
curl 7.50.3 (i686-pc-cygwin)
– Rodrigo
1 hour ago
|
show 7 more comments
With --verbose on I can see both with $TOKEN and the plain text (working one) are giving the exact same authorization: bearer text. Yet one works and the other doesn't.
– Rodrigo
1 hour ago
Have you tried-H "authorization: bearer ${TOKEN}"?
– Samuel P.
1 hour ago
Yes. Same issue. Tried all possible combinations of variable display. Not sure if this is some kind of bug with Curl itself.
– Rodrigo
1 hour ago
Which version of curl are you using (curl --version)?
– Samuel P.
1 hour ago
curl 7.50.3 (i686-pc-cygwin)
– Rodrigo
1 hour ago
With --verbose on I can see both with $TOKEN and the plain text (working one) are giving the exact same authorization: bearer text. Yet one works and the other doesn't.
– Rodrigo
1 hour ago
With --verbose on I can see both with $TOKEN and the plain text (working one) are giving the exact same authorization: bearer text. Yet one works and the other doesn't.
– Rodrigo
1 hour ago
Have you tried
-H "authorization: bearer ${TOKEN}"?– Samuel P.
1 hour ago
Have you tried
-H "authorization: bearer ${TOKEN}"?– Samuel P.
1 hour ago
Yes. Same issue. Tried all possible combinations of variable display. Not sure if this is some kind of bug with Curl itself.
– Rodrigo
1 hour ago
Yes. Same issue. Tried all possible combinations of variable display. Not sure if this is some kind of bug with Curl itself.
– Rodrigo
1 hour ago
Which version of curl are you using (
curl --version)?– Samuel P.
1 hour ago
Which version of curl are you using (
curl --version)?– Samuel P.
1 hour ago
curl 7.50.3 (i686-pc-cygwin)
– Rodrigo
1 hour ago
curl 7.50.3 (i686-pc-cygwin)
– Rodrigo
1 hour ago
|
show 7 more comments
Rodrigo is a new contributor. Be nice, and check out our Code of Conduct.
Rodrigo is a new contributor. Be nice, and check out our Code of Conduct.
Rodrigo is a new contributor. Be nice, and check out our Code of Conduct.
Rodrigo is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f505966%2fpassing-variable-to-authorization-bearer-header-with-curl-and-bash%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How did you set
TOKEN? If you useset -xand then run thecurlcommand, what does the shell show as the argument to-H?– ilkkachu
2 hours ago
$TOKEN was set just plainly on top of the script as: TOKEN="iUhYMrTBdx1GG97Bd99YqrbPojInugjTTnqT8TiRjqgZrZYynljfKpgfao"
– Rodrigo
2 hours ago
well yeah, it looks like it should work, so that's why I asked about what
set -xshows. You are sure that you used double quotes around the"authorization: bearer $TOKEN"as you have posted here, and not single quotes, right?– ilkkachu
1 hour ago
Absolutely sure. I tried all combinations anyway, I updated the post showing that the headers are being passed identically as text, yet when I use the variable it fails.
– Rodrigo
1 hour ago