2

Trying to connect to Salesforce server using Postman, it was showing below error

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

Then tried all the options specified in this article

Tried with 'curl' still unable to connect successfully, posting the curl output below, I really appreciate if experts here can help in solving this problem.

[coderhub@Vikrams-MacBook-Pro ~]$curl -v https://coderhub-dev-ed.my.salesforce.com/services/oauth2/token \
>   -d “grant_type=password” \
>   -d “client_id=3MVG9G9pzCUSkzZvZHR22kuE110FqR94cFlLbdwv0vfxeBw6Ko5R0ofB0R1yAuBdH1kwXXXXXX” \
>   -d “client_secret=A506DB0657E74FBB297F99EB50E491F0AE5E2B766012F90648A7XXXXXX” \
>   -d “username=vikXXXXX@gmail.com” -d “password=XXXXXXXX”
*   Trying 101.53.170.234...
* Connected to XXXXXX-dev-ed.my.salesforce.com (101.53.170.234) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /opt/local/share/curl/curl-ca-bundle.crt
  CApath: none
* TLSv1.2, TLS Unknown, Unknown (22):
* TLSv1.2, TLS handshake, Client hello (1):
* SSLv2, Unknown (22):
* TLSv1.2, TLS handshake, Server hello (2):
* SSLv2, Unknown (22):
* TLSv1.2, TLS handshake, CERT (11):
* SSLv2, Unknown (22):
* TLSv1.2, TLS handshake, Server key exchange (12):
* SSLv2, Unknown (22):
* TLSv1.2, TLS handshake, Server finished (14):
* SSLv2, Unknown (22):
* TLSv1.2, TLS handshake, Client key exchange (16):
* SSLv2, Unknown (20):
* TLSv1.2, TLS change cipher, Client hello (1):
* SSLv2, Unknown (22):
* TLSv1.2, TLS handshake, Finished (20):
* SSLv2, Unknown (20):
* TLSv1.2, TLS change cipher, Client hello (1):
* SSLv2, Unknown (22):
* TLSv1.2, TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*    subject: C=US; ST=California; L=San Francisco; O=salesforce.com, inc.; OU=InfraSec; CN=*.my.salesforce.com
*    start date: 2017-12-03 00:00:00 GMT
*    expire date: 2020-12-02 12:00:00 GMT
*    subjectAltName: coderhub-dev-ed.my.salesforce.com matched
*    issuer: C=US; O=DigiCert Inc; CN=DigiCert SHA2 Secure Server CA
*    SSL certificate verify ok.
* SSLv2, Unknown (23):
> POST /services/oauth2/token HTTP/1.1
> Host: coderhub-dev-ed.my.salesforce.com
> User-Agent: curl/7.42.1
> Accept: */*
> Content-Length: 301
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 301 out of 301 bytes
* SSLv2, Unknown (23):
< HTTP/1.1 400 Bad Request
< Date: Sun, 15 Dec 2019 10:58:53 GMT
< Strict-Transport-Security: max-age=31536002; includeSubDomains
< Public-Key-Pins-Report-Only: pin-sha256="9n0izTnSRF+W4W4JTq51avSXkWhQB8duS2bxVLfzXsY="; pin-sha256="5kJvNEMw0KjrCAu7eXY5HZdvyCS13BbA0VJG1RSP91w="; pin-sha256="njN4rRG+22dNXAi+yb8e3UMypgzPUPHlv4+foULwl1g="; max-age=86400; includeSubDomains; report-uri="https://a.forcesslreports.com/hpkp-report/00D2v000001Yf12m";
< Expect-CT: max-age=86400, report-uri="https://a.forcesslreports.com/Expect-CT-report/00D2v000001Yf12m"
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< X-Robots-Tag: none
< Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private
< Set-Cookie: BrowserId=4d8BbB8pEeqdlbee1ZFndg;Path=/;Domain=.salesforce.com;Expires=Thu, 13-Feb-2020 10:58:53 GMT;Max-Age=5184000
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< X-ReadOnlyMode: false
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< 
* SSLv2, Unknown (23):
* Connection #0 to host coderhub-dev-ed.my.salesforce.com left intact
[coderhub@Vikrams-MacBook-Pro ~]$
  • 2
    See the official OAuth 2.0 flow to see if there's any parameters that need to be adjusted. Maybe you need to URL encode the @ sign like in the official doc's example – Brian Miller Dec 15 '19 at 12:25
  • 1
    @BrianMiller Followed your advice, understood the problem was with the 'authentication' as suggested by 'error_description'. Changed my login password and removed the security token, bingo it worked, could receive the access token. I read somewhere security token to be concatenated to the password? But in my case this is creating problem. – Vikram Dec 15 '19 at 13:21
  • 3
    You've just pasted the complete details of your Connected App, as well as your developer edition username and password, to the Internet. Please change your password immediately and consider replacing the Connected App. I've removed these details from the question text for now. – David Reed Dec 15 '19 at 15:15
1

The problem was with the security key which is concatenated to the password. Problem got sorted once the key was deleted from 'password' value.

Thank @BrianMiller for pointing me in the right direction.

|improve this answer|||||

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.