I'm using curl to connect to a Salesforce org with OAuth (I'm following this tuto and get stuck at step 3):

1) Perform a User Agent OAuth request to get the session data below:

    "instance_url" : "https://mysalesforcedomain.my.salesforce.com",
    "id" : "https://test.salesforce.com/id/00DXXXXXXXXXX/005ZZZZZZZZZZ", 
    "token_type" : "Bearer", 
    "issued_at" : "xxxxxxxxxxxxxxx", 
    "signature" : "labcABCdefDEF............................." 

2) Use the Session data to connect to the Salesforce instance:

curl -H "Authorization: Bearer 00DXXXXXXXXXXXX!YYYYYYYYYYYYYYZZZZZZZZZZZZZZZ" https://mysalesforcedomain.my.salesforce.com/services/data/v44.0

3) Salesforce replies the INVALID_AUTH_HEADER errorCode above:

  "message" : "INVALID_HEADER_TYPE", 
  "errorCode" : "INVALID_AUTH_HEADER" 

Like advised, I've taken care of the '!' char in the access token.

What I tried:

  • Using only quotes keeping the '!' - I get a bash error
  • Use a backslash before the '!' in the session Id - returns INVALID_AUTH_HEADER
  • Use %21 in place of the '!'- returns INVALID_AUTH_HEADER
  • Use an incorrect Session ID - returns INVALID_SESSION_ID

I'm using a macbook with OS X 10.14.4.

What's wrong and what should I do to succeed ?

Thank you for your help

1 Answer 1


I finally found that the problem is related to Bash which interprets the '!' char in a specific way (command history if I understood well). I found about the same question on the Unix stackexchange and 1 of the advice was to deactivate the command history with the command "set +H".

It works fine and you don't even have to escape the '!' character.

Unfortunately, it needs to be done on each Terminal session (I haven't searched how to deactivate this feature permanently). If you ever know how to make it permanent, well let me know

  • Thank you so much @frebde for sharing it. I was also struggling to find the issue.
    – learner
    Commented May 12, 2021 at 18:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .