0

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:

{ 
    "access_token" : "00DXXXXXXXXXXXX!YYYYYYYYYYYYYYZZZZZZZZZZZZZZZ", 
    "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

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.