I'm doin a tutorial o REST connections to Salesforce, and in the Curl connection, i keep having an authentication error. URL: https://trailhead.salesforce.com/content/learn/modules/apex_integration_services/apex_integration_webservices?trail_id=force_com_dev_intermediate
the response:
* Connected to login.salesforce.com (85.222.154.195) port 443 (#0)
* schannel: SSL/TLS connection with login.salesforce.com port 443 (step 1/3)
* schannel: checking server certificate revocation
* schannel: sending initial handshake data: sending 185 bytes...
* schannel: sent initial handshake data: sent 185 bytes
* schannel: SSL/TLS connection with login.salesforce.com port 443 (step 2/3)
* schannel: failed to receive handshake, need more data
* schannel: SSL/TLS connection with login.salesforce.com port 443 (step 2/3)
* schannel: encrypted data got 3290
* schannel: encrypted data buffer: offset 3290 length 4096
* schannel: sending next handshake data: sending 126 bytes...
* schannel: SSL/TLS connection with login.salesforce.com port 443 (step 2/3)
* schannel: encrypted data got 51
* schannel: encrypted data buffer: offset 51 length 4096
* schannel: SSL/TLS handshake complete
* schannel: SSL/TLS connection with login.salesforce.com port 443 (step 3/3)
* schannel: stored credential handle in session cache
> POST /services/oauth2/token HTTP/1.1
> Host: login.salesforce.com
> User-Agent: curl/7.55.1
> Accept: */*
> 'X-PrettyPrint:1'
> Content-Length: 283
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 283 out of 283 bytes
* schannel: client wants to read 102400 bytes
* schannel: encdata_buffer resized 103424
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: encrypted data got 674
* schannel: encrypted data buffer: offset 674 length 103424
* schannel: decrypted data length: 609
* schannel: decrypted data added: 609
* schannel: decrypted data cached: offset 609 length 102400
* schannel: encrypted data length: 36
* schannel: encrypted data cached: offset 36 length 103424
* schannel: decrypted data length: 7
* schannel: decrypted data added: 7
* schannel: decrypted data cached: offset 616 length 102400
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: decrypted data buffer: offset 616 length 102400
* schannel: schannel_recv cleanup
* schannel: decrypted data returned 616
* schannel: decrypted data buffer: offset 0 length 102400
< HTTP/1.1 400 Bad Request
< Date: Sun, 20 Jun 2021 21:52:46 GMT
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private
< Set-Cookie: BrowserId=2XW5PtIREeuzl9vja05dLA; domain=.salesforce.com; path=/; expires=Mon, 20-Jun-2022 21:52:46 GMT; Max-Age=31536000
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< X-ReadOnlyMode: false
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
<
{"error":"invalid_grant","error_description":"authentication failure"}* Connection #0 to host login.salesforce.com left intact
The curl part is also explained in embeded the video, at around 1:35:45.
i verified the command (with enters for clarity):
curl -v https://login.salesforce.com/services/oauth2/token
-d "grant_type=password"
-d "client_id=<your_consumer_key>"
-d "client_secret=<your_consumer_secret>"
-d "username=<your_username>"
-d "password=<your_password_and_security_token>"
-H 'X-PrettyPrint:1'
logged out an in, with that user / password to make sure i got the right one. Renewed the token. Replaced with the info. Tested at this point, got that result.
Here i found i can relax ip restrictions, on Setup > App > manage > IP Relaxation, set them to "Relax IP Restriction". The same error
https://developer.salesforce.com/forums/?id=906F000000099liIAA
Then i found in Network Access, i can set allowed ip addresses. As inserting my ip as maximum and minimum, i whitelisted all IP's. Still the same
btw, i have windows 10, and curl seems ok
# run:
curl --version
# returns
curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
Release-Date: [unreleased]
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL
Any clues?