I am trying to get the Session ID for my salesforce partialbox.
My Code:
curl https://test.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=definitely the correct client id" -d "client_secret=definitely the correct client secret" -d "[email protected]" -d "password=passandsecuritytoken"
What else I did:
I am still getting the error {"error":"invalid_grant","error_description":"authentication failure"}
.
I searched through the SF forums and StackOverflow questions, but I couldn't find any solution for this. Does anyone know, what else could be the problem here?
Revoke the Salesforce App's previous Oauth Tokens: At desktop / laptop Full Site, go to the Advanced User Details, scroll to the Oauth Connected Apps, look for Salesforce for Android / iOS, & click Revoke on those lines. (For more details, please see Manage OAuth-Enabled Connected Apps Access to Your Data.)
When a user tries to login after the session id is expired, the system throws the OAuth error. Solution: Typically, clearing the browser or device cache fixes the problem.
The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.
In the Connected Apps section, click New Connected App. In Basic Information, give the app a name, tab through the api field so it will self-populate in the correct format, and enter a contact email for the app. In the API [Enable OAuth Settings] section, select Enable OAuth Settings.
I'm still confused and I don't know exactly what's going on, but I had your same problem and I was able to "fix" it by doing the following.
First, relax IP restrictions for the app.
Manage Apps -> Connected Apps -> (The name of my app)
Then setting "IP Relaxation" to "Relax IP restrictions".
As far as I know, there are not IP restrictions in the sandbox app I'm working with but I'm still new to this, so maybe they are hiding somewhere.
Second, in my curl command which looked a lot like your I left out the security token, so the password field was just the password.
I don't really know if I've solved my problem but I'm getting back an access token and not the "invalid_grant" error.
I plan on doing some additional investigating to figure out what's going on but I figured, while I had this question up I'd make sure this answer was here.
Make sure you have done this steps.
*Apps -> Manage Connected Apps -> (The name of my app) -> Edit Application -> OAuth Polices Then set "Permitted users" to "All users may self-authorize".
*Manage Apps -> Connected Apps -> (The name of my app) Then set "IP Relaxation" to "Relax IP restrictions".
Try to make a curl request with TLS 1.1 enabled
curl -v https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=xxxxxxxxxxXXXXXXXXXX" -d "client_secret=123456789" -d "[email protected]" -d "password=xxxxxxxxxx"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With