function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aryn Hurst-ClarkAryn Hurst-Clark 

{"error":"invalid_grant","error_description":"authentication failure"}

Hello all, 

sorry if this is already answered somewhere else. I read through similar errors and tried the propoed solutions but nothing worked for me and I am out of ideas.

The error message I get is {"error":"invalid_grant","error_description":"authentication failure"}, the other errors that I found in the forums had more info in the description.

So, I have created a "Connected app", the app has full access, users may self-authorize and the IP restrictions are relaxed (all suggestions I found for similar errors). 

And yes, the password I am passing is the user_password+securty_token.

curl -v https://test.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=***" -d "client_secret=***" -d "username=aryn@***" -d "password=****"


*   Trying 96.43.148.28...
* Connected to test.salesforce.com (96.43.148.28) port 443 (#0)
* TLS 1.2 connection using TLS_RSA_WITH_AES_256_CBC_SHA256
* Server certificate: test.salesforce.com
* Server certificate: Symantec Class 3 Secure Server CA - G4
* Server certificate: VeriSign Class 3 Public Primary Certification Authority - G5
> POST /services/oauth2/token HTTP/1.1
> Host: test.salesforce.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 217
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 217 out of 217 bytes
< HTTP/1.1 400 Bad Request
< Date: Thu, 15 Oct 2015 13:04:32 GMT
< Set-Cookie: BrowserId=9Pq6RC_ERhea3M-zML1BCw;Path=/;Domain=.salesforce.com;Expires=Mon, 14-Dec-2015 13:04:32 GMT
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, no-store
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
<
* Connection #0 to host test.salesforce.com left intact
{"error":"invalid_grant","error_description":"authentication failure"}


What else could cause this problem? Maybe the edition? Or the user account?
James LoghryJames Loghry
First, log into salesforce and view that user's record.  Look for the login history related list and see if that gives you any more details on why the authentication is failing.

Also, does the user have the API permission enabled?

Otherwise, verify the username (and password security token) are correct.  (PasswordSecurityToken is all one string, no + or space in between, if that helps)
Aryn Hurst-ClarkAryn Hurst-Clark
Hello James,

thank you for your response. 

The user probably does not have API permission enabled, because I can not find the box to tick it. 

I checked the login history, but as I expected there is nothing regarding the "Connected App" that I created because I have never succeeded to login thorough it, as it fails on authentication.

Setup/Manage Users/User and nothing that looks like an API permission. This is why I started doubting if it depends on the edition or something else. The user's profile is "System Administrator" if that helps as an info. 

I read this thread https://success.salesforce.com/answers?id=90630000000gr7kAAA and tried the solution with creating a Permission Set (since I could not find it as a permission on a user level), but even then in the long list of permissions to choose from 'API enabled' is not among the options.

We do have a Professional Edition. Could this be the reason? 

Regards,
Aryn
Aryn Hurst-ClarkAryn Hurst-Clark
Hello all, 

I have un update on this. We had API access enabled for our Professional Edition. I tried activating it on a User level as it was suggested, but there is no API enabled box to tick. That is why I created a Permission set with API enabled and then assigned the permission set to the user I am trying to connect with (which is me if it matters, and my level is System Administrator in SalesForce).

So with permission set with API enabled, relaxed IP settings, users self authorize, the password is a concatenation between the password and the user security token I still get the exact same error:

*   Trying 96.43.149.120...
* Connected to test.salesforce.com (96.43.149.120) port 443 (#0)
* TLS 1.2 connection using TLS_RSA_WITH_AES_256_CBC_SHA256
* Server certificate: test.salesforce.com
* Server certificate: Symantec Class 3 Secure Server CA - G4
* Server certificate: VeriSign Class 3 Public Primary Certification Authority - G5
> POST /services/oauth2/token HTTP/1.1
> Host: test.salesforce.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 219
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 219 out of 219 bytes
< HTTP/1.1 400 Bad Request
< Date: Wed, 21 Oct 2015 16:49:54 GMT
< Set-Cookie: BrowserId=C3bqXCA_TfCrGu-fhLKxGw;Path=/;Domain=.salesforce.com;Expires=Sun, 20-Dec-2015 16:49:54 GMT
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, no-store
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
<
* Connection #0 to host test.salesforce.com left intact
{"error":"invalid_grant","error_description":"authentication failure"}
Any help is much appreciated, now I am completely out of ideas. 

Best,
Rali
 
Magyar-Hunor Tamas 1Magyar-Hunor Tamas 1

Heya, I know this is an old question, but I just found smth that I was misunderstanding. So I will put an answer so if others find this googling can carry on doing their work/challenges.

when making ur curl request, your password is not enough. you must get your security token too and just append it to your password. so your curl would look like this:

 

curl -v https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=3MVG9xB234234ir9oEkwVnY.SNB9Eg1W9NBZ9q234234SFPYtSvZ0.67N9EGKa70.TK0fy55BGBfgsda_DgtkxK2sd2dMMIa0KTY" -d "client_secret=F15F12569E45E053D03905B5309ADC99ABF818E850D4FD1698543FA3954CE1FF" -d "username=yoursalesforceuser@name.com" -d "password=YourPassword8hDozBx2ca3fm2uQPjZEHiW3" -H 'X-PrettyPrint:1'

 

I hope this helps.