Skip to content

Commit 5fed266

Browse files
author
Dale Francum
committed
Added ability to pass in a session_id and instance to the init.
1 parent a307e16 commit 5fed266

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

README.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Usage
88
-----
99
To use API classes one needs to create a session first by instantiating SfdcSession class and passing login details to the constructor.
1010

11+
One method is to pass in the username, password, and token:
1112
.. code-block:: python
1213
1314
from sfdclib import SfdcSession
@@ -20,6 +21,22 @@ To use API classes one needs to create a session first by instantiating SfdcSess
2021
)
2122
s.login()
2223
24+
A second method, if you've already logged in elsewhere, is to pass in the instance and session_id. This method does not require calling login().
25+
.. code-block:: python
26+
27+
from sfdclib import SfdcSession
28+
29+
s = SfdcSession(
30+
'username': None,
31+
'password': None,
32+
'token': None,
33+
'is_sandbox': True,
34+
'api_version': "37.0",
35+
'session_id': 'thiswillbeaverylongstringofcharactersincludinglettersspacesandsymbols',
36+
'instance': 'custom-sf-site.my'
37+
)
38+
# Notice we are not calling the login() method for this example.
39+
2340
Then create an instance of corresponding API class passing session object.
2441

2542
.. code-block:: python

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='sfdclib',
8-
version='0.2.15',
8+
version='0.2.16',
99
author='Andrey Shevtsov',
1010
author_email='[email protected]',
1111
packages=['sfdclib'],

sfdclib/session.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ class SfdcSession(Session):
2828

2929
def __init__(
3030
self, username=None, password=None, token=None,
31-
is_sandbox=False, api_version=_DEFAULT_API_VERSION):
31+
is_sandbox=False, api_version=_DEFAULT_API_VERSION,
32+
session_id=None, instance=None):
3233
super(SfdcSession, self).__init__()
3334
self._username = username
3435
self._password = password
3536
self._token = token
3637
self._is_sandbox = is_sandbox
3738
self._api_version = api_version
38-
self._session_id = None
39-
self._instance = None
39+
self._session_id = session_id
40+
self._instance = instance
4041

4142
def login(self):
4243
url = self.construct_url(self.get_soap_api_uri())

0 commit comments

Comments
 (0)