@@ -76,11 +76,12 @@ def _set_logging(self):
7676
7777 return logger
7878
79- def _get_request_format (self , api = None , call = None ):
79+ def _get_request_format (self , api = None , call = None , use_cookie_auth = False ):
8080 if not api : api = self .API_TYPE_SOAP
8181 return {
8282 'api' : api ,
8383 'call' : call ,
84+ 'use_cookie_auth' : use_cookie_auth ,
8485 'query' : None ,
8586 'data' : None ,
8687 }
@@ -108,6 +109,9 @@ def _request(self, request, auth_required=True):
108109 REST API calls this will be a dict converted to JSON automatically
109110 by this method
110111
112+ use_cookie_auth
113+ Whether or not to use an HTTP Cookie in lieu of a querystring for authorization
114+
111115 ## Output
112116
113117 Returns a dict:
@@ -139,9 +143,9 @@ def _request(self, request, auth_required=True):
139143 # add the authentication parameters
140144 if auth_required :
141145 if request ['api' ] == self .API_TYPE_REST :
142- # sID is a query string
143- if not request ['query' ]: request ['query' ] = {}
144- request ['query' ]['sID' ] = self ._sessions [self .API_TYPE_REST ]
146+ if not request [ 'use_cookie_auth' ]: # sID is a query string
147+ if not request ['query' ]: request ['query' ] = {}
148+ request ['query' ]['sID' ] = self ._sessions [self .API_TYPE_REST ]
145149 elif request ['api' ] == self .API_TYPE_SOAP :
146150 # sID is part of the data
147151 if not request ['data' ]: request ['data' ] = {}
@@ -182,6 +186,11 @@ def _request(self, request, auth_required=True):
182186
183187 # authentication calls don't accept the Accept header
184188 if request ['call' ].startswith ('authentication' ): del (headers ['Accept' ])
189+
190+ # some rest calls use a cookie to pass the sID
191+ if request ['api' ] == self .API_TYPE_REST and request ['use_cookie_auth' ]:
192+ headers ['Cookie' ] = 'sID="{}"' .format (self ._sessions [self .API_TYPE_REST ])
193+
185194 if request ['api' ] == self .API_TYPE_REST and request ['call' ] in [
186195 'apiVersion' ,
187196 'status/manager/ping'
@@ -262,6 +271,7 @@ def _request(self, request, auth_required=True):
262271 # report the exception as 'info' because it's not fatal and the data is
263272 # still captured in result['raw']
264273 self .log ("Could not convert response from call {} to JSON. Threw exception:\n \t {}" .format (request ['call' ], json_err ), level = 'info' )
274+
265275 return result
266276
267277 def _prefix_keys (self , prefix , d ):
@@ -458,7 +468,6 @@ def to_dict(self):
458468
459469 return result
460470
461-
462471class CoreList (list ):
463472 def __init__ (self , * args ):
464473 super (CoreList , self ).__init__ (args )
0 commit comments