You need to sign in to do that
Don't have an account?
Access to REST API SALESFORCE using username and password?
Hello, I spend a lot of time in search how to use the rest api, but only i find information to use the rest api with oAuth, but in dont want to use oauth, i want to type the username and password in the code and this is all, i want to make an app where the client dont see any rest api comunication, I mean execute the apex code in background.
I find a code in http://208.69.57.141/index.php/2011/05/using-the-salesforce-rest-api-with-javascript-and-jquery-in-visualforce-pages-using-apex/#comments
But show me a error [{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]
Thanks
You can use the username and password flow in oauth if you wish, but even better would be to use the server to server flow.
https://login.salesforce.com/help/doc/en/remoteaccess_authenticate.htm
I get this error:
{"error":"invalid_grant","error_description":"authentication failure - Failed: API security token required"}
when calling this:
curl -k -d "grant_type=password&clientid=clientIdclient_secret=clientsecret&username=mysuserid&password=mypassword" https://login.salesforce.com/services/oauth2/token
I'm using my actual username and password in the request.
Thanks for any help.
You need to use your api security token in addition to your password, see the online help on identity confirmation.
The link above that dkador provided indicates you can just send the username/password and then the response will include the access token which is what I'm after. I'm just looking for a quick and easy way to get my access token. Thanks.
If you're not connecting from a trusted IP address, you need to also include the api security token.
Hi ,
I used mozilla poster to get access token .I think you have to use oauth if you are using REST API's.There is no alternative.With username and password too you will get acess token and then using this you can easily call the apex code.
Here is my blog may be it can help you .
http://cloudyworlds.blogspot.in/2012/08/using-poster-mozilla-tool-to-get-oauth.html?spref=bl
Use the above and implement same in your code.
Thanks,
Mohith.
This same issue has been frustrating me for the last hour, but I finally worked it out!
YOU NEED TO APPEND YOUR SECURITY TOKEN (i.e. the one associated with your username) TO YOUR PASSWORD, AS A SINGLE STRING!!
So for instance:
curl -d "grant_type=password&client_id={client_id}&client_secret={client_secret}&username=user@domain.com&password={Password}{SecurityToken}" "https://login.salesforce.com/services/oauth2/token"
... will return
{"id":"https://login.salesforce.com/id/xxxxxxxxxxxxx","issued_at":"1347503304385","instance_url":"https://ap1.salesforce.com","signature":"xxxxxxxxxxxxx","access_token":"XXXXtokenXXXXXX"}
[tested 13/09/2012]
I guess the other option would be to register your IP address range with Salesforce, which I believe precludes the need for the Security Token... but that's not workable for, say, mobile scenarios.
Hope this saves others some headaches!
:) AB
Thanks. That worked.
what is client_id in the example above when I have no Connected App registered, just user with API permission enabled?
Thank you
Named Credentials - Setup (https://sfdcfanboy.com/2018/01/15/named-credentials-setup/)
Named Credentials - Code (https://sfdcfanboy.com/2018/01/15/named-credentials-code/)
The password+token combination is also needed while changing user's password in UI. Nothing leads to this form of password enteting on the interface
https://www.sfdc-lightning.com/2019/01/salesforce-rest-api-integration.html