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
Sam AlterSam Alter 

acess Salesforce from a web-service


Hello!

I'm trying to access Salesforce from a web-service, hosted externally, say on the Amazon cloud or another web server. The web-service needs to login to Salesforce, query records, and update records periodically. The trigger mechanism is irrelevant. I have a Python script within the web-service, that uses simple-salesforce to login to Salesforce, query and update records. Now, the script works fine from my desktop, but when I upload to the cloud (say, Amazon web-servers), I get a "permission denied". Is my security token limited to my desktop? I am able to login to salesforce from external IP addresses (home), but not from this web-service hosted on the cloud.

Any ideas?

Thanks!
Sam
 
Varun PareekVarun Pareek
Are there any IP restrictions that have been set in your Salesforce instance? If yes, you would have to add the IP address of the "cloud" server of the external application to Salesforce instance.

P.S - Security token is tied to a user.
Sam AlterSam Alter
Yes, I am aware that the token is tied to a user. There are no IP resttrictions in the Salesforce instance either. The user token is embedded in the web-service that is trying to talk to Salesforce (not secure, but taking it one step at a time).
Varun PareekVarun Pareek
Is it possible to bifurcate the login and the remaining process in two separate flows to pin point that it is the login() call that is failing?
Sam AlterSam Alter
Yes, it is. I include breakpoints that spit some text. It breaks right where I'm defining the Salesforce(username, pwd, security_token) instance using the simple_salesforce API:
https://pypi.python.org/pypi/simple-salesforce

The same works when I host the web-service on my local machine. But when the web-service is on the cloud, this gives me a clear "access denied" error. I'll try to reproduce the error and post it later.
Varun PareekVarun Pareek
Okay, can you try this - Go to your user's profile (same user which is logging from python). Whitelist the IP range from 0.0.0.0 to 255.255.255.255.

Go to python - User your username and password (WITHOUT the security token this time)