Skip to content

Instantly share code, notes, and snippets.

@Ed1123
Created October 16, 2023 19:06
Show Gist options
  • Save Ed1123/91d848ee758a50c471f45f497a40f119 to your computer and use it in GitHub Desktop.
Save Ed1123/91d848ee758a50c471f45f497a40f119 to your computer and use it in GitHub Desktop.
Simple funciton to connect to Salesforce (and sandbox when needed)
def connect_salesforce(username: str, password: str, security_token: str, is_test: bool) -> Salesforce:
'''Returns a Salesforce connection object. If test, it'll connect to Sf sandbox'''
domain = None
if is_test:
domain = 'test'
username += '.full'
return Salesforce(username, password, security_token, domain=domain)
sf = connect_salesforce(username, password, security_token, False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment