From dfdf4605b3e244e48c5c4bc022af83b3409a7160 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 5 Jul 2021 14:23:39 +0200 Subject: [PATCH] Use the original instance_url for soap auth The explicitly set server/instance URL was being overriden by what the server returned. There are however probably good reasons for the original URL to be set by the developer. Ignoring the developer's decision without giving an option to override, forces the developer to copy-paste and rewrite code that uses the method. This commit makes that unnecessary. Fixes #21 : SOAP auth overwrites instance URL --- salesforce_api/login.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/salesforce_api/login.py b/salesforce_api/login.py index 0d6e67f..8afbb90 100644 --- a/salesforce_api/login.py +++ b/salesforce_api/login.py @@ -97,9 +97,7 @@ def soap(instance_url: str, username: str, password: str = None, security_token: if response.has('soapenv:Envelope/soapenv:Body/loginResponse/result/sessionId'): session_id = response.get_value('soapenv:Envelope/soapenv:Body/loginResponse/result/sessionId') - server_url = response.get_value('soapenv:Envelope/soapenv:Body/loginResponse/result/serverUrl') - instance = re.match(r'(https://(.*).salesforce\.com/)', server_url).group(1) - return plain_access_token(access_token=session_id, instance_url=instance, session=session, api_version=api_version) + return plain_access_token(access_token=session_id, instance_url=instance_url, session=session, api_version=api_version) if not response.has('soapenv:Envelope/soapenv:Body/soapenv:Fault/faultcode'): raise exceptions.AuthenticationError