0

We are currently using the following command to generate a token, however the server keeps returning an error.

Command:

curl -v https://{instance}.salesforce.com/services/oauth2/token
    -d "grant_type=password"
    -d "client_id={appKey}"
    -d "client_secret= {appSecret}"
    -d "username={loginUserName}"
    -d "password={Key}{Token}"
    -H "X-PrettyPrint: 1"

Error:

{
    "error" : "invalid_grant",
    "error_description" : "authentication failure"
    * Connection #0 to host login.salesforce.com left intact
}

Things we've tried (including reading documentation and Q&A both on SF Community and here):

  1. Using login.salesforce.com rather than the instance (naXX)
  2. Using test.salesforce.com rather than the instance (naXX)
  3. Not using a password token (with different endpoints from #1,#2)
  4. Setting IP Restrictions to relaxed
  5. Setting users to authenticate themselves
  6. Setting network access to the IP being used to send the command (both start and end IP.)
  7. Trying alternate grant_type (s) to see what happened (alternate errors for those respective auth flows.)
  8. Sending the parameters as one query string

EDIT

I have posted the proper answer below.

2
  • 1
    Please don't just blindly blame the user base. Regardless, the information from your last edit is not part of what you are trying to ask, so I removed it in addition to cleaning up your list formatting.
    – Adrian Larson
    Jun 28, 2018 at 16:23
  • Hi Adrian. I've further edited my edit in response to your edits, and responded to your comment in my answer below. Given the "recommended deletions" under the "From Review" link, the user base address was warranted. The answer remains valid (including its brevity), and at this point, it is a waste of time to continue fighting this battle. For anyone else who stumbles upon this question, I do hope the answer below helps. Jun 28, 2018 at 16:45

1 Answer 1

1

The user type (Eg: "Administrator") must have the connected app enabled in their profile.

6
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
    – Reshma
    Jun 28, 2018 at 4:53
  • I am the author, so yes, it does answer the question. Jun 28, 2018 at 15:34
  • 1
    Hi SFExplorer, I agree this answer is likely useful for future visitors who encounter the same issue, but answers which are this short actually get flagged automatically. Please take a moment to read How to Answer. In this particular case, linking to articles which helped discover the issue would greatly improve the quality of your answer. And any time you include a link, it is highly advisable to cite the relevant content here in a blockquote (you start the line with a > character).
    – Adrian Larson
    Jun 28, 2018 at 16:22
  • Hi Adrian, thank you for the clarification on automatic flagging. When I looked at the "From Review" link under Reshma's post, I noticed the two "Recommended deletions" from particular users. In this particular case, there is obviously an exception to the automatic flag. In regards to particular links, it was actually trial and error on my part. Thus, the brevity of the answer is warranted. Jun 28, 2018 at 16:41
  • 2
    Once the system flags an answer, it enters a Review Queue where many users can vote on whether or not the automatic flag has merit. I still highly recommend you edit your answer to include one or two of the most helpful links you found.
    – Adrian Larson
    Jun 28, 2018 at 16:49

You must log in to answer this question.

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