title: curl and bash script, doing a post request with a bearer token
body: <p>Please educate me!</p>
  
  <p>My script is:</p>
  
  <pre><code>#!/usr/bin/env bash
  
  username="zDISABLEDc"
  rand="Z01c20a936f474b"
  
  single_quote="'"
  curl_string_part1_="-X PUT https://api.secretkgbwebsite.com/api/v4.1/user/$username "
  curl_string_part2_='-H "Authorization: bearer 00000000-4cd9-4bc6-90da-5d43a155f30e" -H "Cache-Control: no-cache" -H "Content-Type: application/json" -H "Postman-Token: 351e4bf1-04a2-4c99-8a21-21a05f51244a" -d '
  curl_string_part3_='{"password": "'
  curl_string_part4_='"}'
  
  curl_string_complete="$curl_string_part1_$curl_string_part2_$single_quote$curl_string_part3_$rand$curl_string_part4_$single_quote"
  
  echo $curl_string_complete
  echo " "
  success=0
  curl $curl_string_complete &amp;&amp; success=1
  
  if ((success)); then
      echo "SUCCESS. password has been reset to : "
      echo $rand
  else
      echo "problem sending and resetting password."
  fi
  </code></pre>
  
  <p>The errors I get are:</p>
  
  <blockquote>
    <p>{"error":"unauthorized","error_description":"An Authentication object was not found in the SecurityContext"}curl: (6) Could not resolve host: bearer<br>
        curl: (6) Could not resolve host: 00000000-4cd9-4bc6-90da-5d43a155f30e"<br>
        curl: (6) Could not resolve host: no-cache"<br>
        curl: (6) Could not resolve host: application<br>
        curl: (6) Could not resolve host: 351e4bf1-04a2-4c99-8a21-21a05f51244a"<br>
        curl: (3) [globbing] unmatched close brace/bracket in column 18  </p>
  </blockquote>
  
  <p>Now the annoying thing is that if I run the line that my program echoes out (this line: <code>echo $curl_string_complete</code>) with curl, curl is happy and runs the line without a problem.</p>