Skip to content

Commit

Permalink
Use the original instance_url for soap auth
Browse files Browse the repository at this point in the history
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
  • Loading branch information
54sledgehammer45 committed Jul 5, 2021
1 parent 37ed67b commit dfdf460
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions salesforce_api/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dfdf460

Please sign in to comment.