@@ -94,6 +94,7 @@ class PlexServer(PlexObject):
9494 def __init__ (self , baseurl = None , token = None , session = None , timeout = None ):
9595 self ._baseurl = baseurl or CONFIG .get ('auth.server_baseurl' , 'http://localhost:32400' )
9696 self ._token = logfilter .add_secret (token or CONFIG .get ('auth.server_token' ))
97+ self ._showSecrets = CONFIG .get ('log.show_secrets' , '' ).lower () == 'true'
9798 self ._session = session or requests .Session ()
9899 self ._library = None # cached library
99100 self ._settings = None # cached settings
@@ -265,7 +266,7 @@ def downloadDatabases(self, savepath=None, unpack=False):
265266 unpack (bool): Unpack the zip file.
266267 """
267268 url = self .url ('/diagnostics/databases' )
268- filepath = utils .download (url , None , savepath , self ._session , unpack = unpack )
269+ filepath = utils .download (url , self . _token , None , savepath , self ._session , unpack = unpack )
269270 return filepath
270271
271272 def downloadLogs (self , savepath = None , unpack = False ):
@@ -276,7 +277,7 @@ def downloadLogs(self, savepath=None, unpack=False):
276277 unpack (bool): Unpack the zip file.
277278 """
278279 url = self .url ('/diagnostics/logs' )
279- filepath = utils .download (url , None , savepath , self ._session , unpack = unpack )
280+ filepath = utils .download (url , self . _token , None , savepath , self ._session , unpack = unpack )
280281 return filepath
281282
282283 def check_for_update (self , force = True , download = False ):
@@ -410,11 +411,13 @@ def transcodeImage(self, media, height, width, opacity=100, saturation=100):
410411 if media :
411412 transcode_url = '/photo/:/transcode?height=%s&width=%s&opacity=%s&saturation=%s&url=%s' % (
412413 height , width , opacity , saturation , media )
413- return self .url (transcode_url )
414+ return self .url (transcode_url , includeToken = True )
414415
415- def url (self , key ):
416- """ Build a URL string with proper token argument. """
417- if self ._token :
416+ def url (self , key , includeToken = None ):
417+ """ Build a URL string with proper token argument. Token will be appended to the URL
418+ if either includeToken is True or CONFIG.log.show_secrets is 'true'.
419+ """
420+ if self ._token and (includeToken or self ._showSecrets ):
418421 delim = '&' if '?' in key else '?'
419422 return '%s%s%sX-Plex-Token=%s' % (self ._baseurl , key , delim , self ._token )
420423 return '%s%s' % (self ._baseurl , key )
0 commit comments