spotifywebapiPython 1.0.85__py3-none-any.whl → 1.0.86__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of spotifywebapiPython might be problematic. Click here for more details.

Files changed (22) hide show
  1. {spotifywebapiPython-1.0.85.dist-info → spotifywebapiPython-1.0.86.dist-info}/METADATA +1 -1
  2. {spotifywebapiPython-1.0.85.dist-info → spotifywebapiPython-1.0.86.dist-info}/RECORD +22 -22
  3. spotifywebapipython/const.py +6 -1
  4. spotifywebapipython/docs/__init__.html +8 -2
  5. spotifywebapipython/docs/index.html +2 -2
  6. spotifywebapipython/docs/search.js +1 -1
  7. spotifywebapipython/docs/spotifywebapiPython/const.html +20 -3
  8. spotifywebapipython/docs/spotifywebapiPython/saappmessages.html +2 -2
  9. spotifywebapipython/docs/spotifywebapiPython/sautils.html +2 -2
  10. spotifywebapipython/docs/spotifywebapiPython/spotifyapierror.html +2 -2
  11. spotifywebapipython/docs/spotifywebapiPython/spotifyapimessage.html +2 -2
  12. spotifywebapipython/docs/spotifywebapiPython/spotifyauthtoken.html +2 -2
  13. spotifywebapipython/docs/spotifywebapiPython/spotifyclient.html +22 -4
  14. spotifywebapipython/docs/spotifywebapiPython/spotifydiscovery.html +2 -2
  15. spotifywebapipython/docs/spotifywebapiPython/spotifywebapiauthenticationerror.html +2 -2
  16. spotifywebapipython/docs/spotifywebapiPython/spotifywebapierror.html +2 -2
  17. spotifywebapipython/oauthcli/authclient.py +22 -5
  18. spotifywebapipython/spotifyclient.py +35 -6
  19. spotifywebapipython/zeroconfapi/zeroconfconnect.py +20 -1
  20. {spotifywebapiPython-1.0.85.dist-info → spotifywebapiPython-1.0.86.dist-info}/LICENSE +0 -0
  21. {spotifywebapiPython-1.0.85.dist-info → spotifywebapiPython-1.0.86.dist-info}/WHEEL +0 -0
  22. {spotifywebapiPython-1.0.85.dist-info → spotifywebapiPython-1.0.86.dist-info}/top_level.txt +0 -0
@@ -32,6 +32,7 @@ from .const import (
32
32
  SPOTIFY_DESKTOP_APP_CLIENT_ID,
33
33
  SPOTIFY_DEFAULT_MARKET,
34
34
  SPOTIFY_WEBAPI_URL_BASE,
35
+ SPOTIFYWEBAPIPYTHON_TOKEN_CACHE_FILE,
35
36
  TRACE_METHOD_RESULT,
36
37
  TRACE_METHOD_RESULT_TYPE,
37
38
  TRACE_METHOD_RESULT_TYPE_CACHED,
@@ -77,6 +78,7 @@ class SpotifyClient:
77
78
  def __init__(self,
78
79
  manager:PoolManager=None,
79
80
  tokenStorageDir:str=None,
81
+ tokenStorageFile:str=None,
80
82
  tokenUpdater:Callable=None,
81
83
  zeroconfClient:Zeroconf=None,
82
84
  spotifyConnectUsername:str=None,
@@ -91,9 +93,12 @@ class SpotifyClient:
91
93
  manager (urllib3.PoolManager):
92
94
  The manager for HTTP requests to the device.
93
95
  tokenStorageDir (str):
94
- The directory path that will contain the `tokens.json` file.
96
+ The directory path that will contain the authorization Token Cache file.
95
97
  A null value will default to the platform specific storage location:
96
98
  Example for Windows OS = `C:\ProgramData\SpotifyWebApiPython`
99
+ tokenStorageFile (str):
100
+ The filename and extension of the authorization Token Cache file.
101
+ Default is `SpotifyWebApiPython_tokens.json`.
97
102
  tokenUpdater (Callable):
98
103
  A method to call when a token needs to be refreshed by an external provider.
99
104
  The defined method is called with no parameters, and should return a token dictionary.
@@ -143,6 +148,11 @@ class SpotifyClient:
143
148
  if (spotifyConnectPassword is None) or (not isinstance(spotifyConnectPassword,str)):
144
149
  raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % ("__init__", 'spotifyConnectPassword'), logsi=_logsi)
145
150
 
151
+ # verify token storage filename was specified.
152
+ if tokenStorageFile is None:
153
+ tokenStorageFile = SPOTIFYWEBAPIPYTHON_TOKEN_CACHE_FILE
154
+
155
+ # initialize storage.
146
156
  self._AuthToken:SpotifyAuthToken = None
147
157
  self._AuthClient:AuthClient = None
148
158
  self._ConfigurationCache:dict = {}
@@ -152,6 +162,7 @@ class SpotifyClient:
152
162
  self._SpotifyConnectLoginId:str = spotifyConnectLoginId
153
163
  self._SpotifyConnectDiscoveryTimeout:float = float(spotifyConnectDiscoveryTimeout)
154
164
  self._TokenStorageDir:str = tokenStorageDir
165
+ self._TokenStorageFile:str = tokenStorageFile
155
166
  self._TokenUpdater:Callable = tokenUpdater
156
167
  self._UserProfile:UserProfile = None
157
168
  self._ZeroconfClient = zeroconfClient
@@ -294,6 +305,14 @@ class SpotifyClient:
294
305
  return self._TokenStorageDir
295
306
 
296
307
 
308
+ @property
309
+ def TokenStorageFile(self) -> str:
310
+ """
311
+ The filename and extension of the authorization token cache file.
312
+ """
313
+ return self._TokenStorageFile
314
+
315
+
297
316
  @property
298
317
  def UserProfile(self) -> UserProfile:
299
318
  """
@@ -6192,7 +6211,8 @@ class SpotifyClient:
6192
6211
  discoverResult.HostIpPort,
6193
6212
  discoverResult.SpotifyConnectCPath,
6194
6213
  useSSL=False,
6195
- tokenStorageDir=self.TokenStorageDir)
6214
+ tokenStorageDir=self.TokenStorageDir,
6215
+ tokenStorageFile=self.TokenStorageFile)
6196
6216
 
6197
6217
  # if a different user context has control of the device then we need to disconnect
6198
6218
  # the current user context before connecting a different user.
@@ -8252,7 +8272,8 @@ class SpotifyClient:
8252
8272
  discoverResult.HostIpPort,
8253
8273
  discoverResult.SpotifyConnectCPath,
8254
8274
  useSSL=False,
8255
- tokenStorageDir=self.TokenStorageDir)
8275
+ tokenStorageDir=self.TokenStorageDir,
8276
+ tokenStorageFile=self.TokenStorageFile)
8256
8277
 
8257
8278
  # if we did not refresh the device list, then query the device for real-time status; just in
8258
8279
  # case the device was disconnected after the last cache refresh. note that we only do this
@@ -8270,9 +8291,10 @@ class SpotifyClient:
8270
8291
  # check if the Spotify Desktop Application Client oauth2 token is defined.
8271
8292
  hasToken:bool = AuthClient.HasTokenForKey(
8272
8293
  clientId=SPOTIFY_DESKTOP_APP_CLIENT_ID,
8273
- tokenStorageDir=self.TokenStorageDir,
8274
8294
  tokenProviderId='SpotifyWebApiAuthCodePkce',
8275
8295
  tokenProfileId=self._SpotifyConnectLoginId,
8296
+ tokenStorageDir=self.TokenStorageDir,
8297
+ tokenStorageFile=self.TokenStorageFile,
8276
8298
  )
8277
8299
 
8278
8300
  if not hasToken:
@@ -8501,7 +8523,8 @@ class SpotifyClient:
8501
8523
  discoverResult.HostIpPort,
8502
8524
  discoverResult.SpotifyConnectCPath,
8503
8525
  useSSL=False,
8504
- tokenStorageDir=self.TokenStorageDir)
8526
+ tokenStorageDir=self.TokenStorageDir,
8527
+ tokenStorageFile=self.TokenStorageFile)
8505
8528
  info = zconn.GetInformation()
8506
8529
 
8507
8530
  except Exception as ex:
@@ -8516,7 +8539,8 @@ class SpotifyClient:
8516
8539
  discoverResult.HostIpPort,
8517
8540
  discoverResult.SpotifyConnectCPath,
8518
8541
  useSSL=False,
8519
- tokenStorageDir=self.TokenStorageDir)
8542
+ tokenStorageDir=self.TokenStorageDir,
8543
+ tokenStorageFile=self.TokenStorageFile)
8520
8544
  info = zconn.GetInformation()
8521
8545
 
8522
8546
  # update HostIpAddress in discovery result so it knows to use the alias
@@ -14438,6 +14462,7 @@ class SpotifyClient:
14438
14462
  clientSecret=clientSecret,
14439
14463
  oauth2Client=WebApplicationClient(client_id=clientId), # required for grant_type = authorization_code
14440
14464
  tokenStorageDir=self._TokenStorageDir,
14465
+ tokenStorageFile=self._TokenStorageFile,
14441
14466
  tokenProviderId='SpotifyWebApiAuthCode',
14442
14467
  tokenProfileId=tokenProfileId,
14443
14468
  tokenUpdater=self._TokenUpdater
@@ -14620,6 +14645,7 @@ class SpotifyClient:
14620
14645
  clientSecret=None, # client_secret not used for authorization code with pkce type
14621
14646
  oauth2Client=WebApplicationClient(client_id=clientId), # required for grant_type = authorization_code
14622
14647
  tokenStorageDir=self._TokenStorageDir,
14648
+ tokenStorageFile=self._TokenStorageFile,
14623
14649
  tokenProviderId='SpotifyWebApiAuthCodePkce',
14624
14650
  tokenProfileId=tokenProfileId,
14625
14651
  tokenUpdater=self._TokenUpdater
@@ -14737,6 +14763,7 @@ class SpotifyClient:
14737
14763
  clientSecret=clientSecret,
14738
14764
  oauth2Client=BackendApplicationClient(client_id=clientId), # required for grant_type = client_credentials
14739
14765
  tokenStorageDir=self._TokenStorageDir,
14766
+ tokenStorageFile=self._TokenStorageFile,
14740
14767
  tokenProviderId='SpotifyWebApiClientCredentials',
14741
14768
  tokenProfileId=tokenProfileId,
14742
14769
  tokenUpdater=self._TokenUpdater
@@ -14835,6 +14862,7 @@ class SpotifyClient:
14835
14862
  scope=token.get('scope'),
14836
14863
  clientId=clientId,
14837
14864
  tokenStorageDir=self._TokenStorageDir,
14865
+ tokenStorageFile=self._TokenStorageFile,
14838
14866
  tokenProviderId='SpotifyWebApiOAuth2Token',
14839
14867
  tokenProfileId=tokenProfileId,
14840
14868
  tokenUpdater=self._TokenUpdater
@@ -14894,6 +14922,7 @@ class SpotifyClient:
14894
14922
  msg:str = 'SpotifyClient:'
14895
14923
  msg = "%s\n ConfigurationCache key count=%d" % (msg, len(self._ConfigurationCache))
14896
14924
  msg = "%s\n TokenStorageDir='%s'" % (msg, self._TokenStorageDir)
14925
+ msg = "%s\n TokenStorageFile='%s'" % (msg, self._TokenStorageFile)
14897
14926
  if self._UserProfile is not None:
14898
14927
  msg = "%s\n User DisplayName='%s' (%s)" % (msg, self._UserProfile.DisplayName, self._UserProfile.Id)
14899
14928
  return msg
@@ -21,6 +21,7 @@ from ..const import (
21
21
  SPOTIFY_API_AUTHORIZE_URL,
22
22
  SPOTIFY_API_TOKEN_URL,
23
23
  SPOTIFY_DESKTOP_APP_CLIENT_ID,
24
+ SPOTIFYWEBAPIPYTHON_TOKEN_CACHE_FILE,
24
25
  TRACE_METHOD_RESULT,
25
26
  TRACE_MSG_DELAY_DEVICE,
26
27
  )
@@ -61,6 +62,7 @@ class ZeroconfConnect:
61
62
  version:str=None,
62
63
  useSSL:bool=False,
63
64
  tokenStorageDir:str=None,
65
+ tokenStorageFile:str=None,
64
66
  tokenAuthInBrowser:bool=False,
65
67
  ) -> None:
66
68
  """
@@ -83,10 +85,13 @@ class ZeroconfConnect:
83
85
  otherwise, False to utilize HTTP.
84
86
  Default is False (HTTP).
85
87
  tokenStorageDir (str):
86
- The directory path that will contain the `tokens.json` cache file.
88
+ The directory path that will contain the Token Cache file.
87
89
  This is used for Spotify Connect devices that utilize the `authorization_code` token type.
88
90
  A null value will default to the platform specific storage location:
89
91
  Example for Windows OS = `C:\ProgramData\SpotifyWebApiPython`
92
+ tokenStorageFile (str):
93
+ The filename and extension of the Token Cache file.
94
+ Default is `SpotifyWebApiPython_tokens.json`.
90
95
  tokenAuthInBrowser (bool):
91
96
  True to allow authorization access token to be authorized if necessary via an
92
97
  interactive browser; otherwise, False.
@@ -103,11 +108,16 @@ class ZeroconfConnect:
103
108
  if (version is None) or (not isinstance(version,str)):
104
109
  version = ZeroconfConnect.SPOTIFY_CONNECT_CLIENT_VERSION_DEFAULT
105
110
 
111
+ # verify token storage filename was specified.
112
+ if tokenStorageFile is None:
113
+ tokenStorageFile = SPOTIFYWEBAPIPYTHON_TOKEN_CACHE_FILE
114
+
106
115
  # initialize storage.
107
116
  self._CPath:str = cpath
108
117
  self._HostIpPort:int = hostIpPort
109
118
  self._HostIpAddress:str = hostIpAddress
110
119
  self._TokenStorageDir:str = tokenStorageDir
120
+ self._TokenStorageFile:str = tokenStorageFile
111
121
  self._TokenAuthInBrowser:str = tokenAuthInBrowser
112
122
  self._UseSSL:bool = useSSL
113
123
  self._Version:str = version
@@ -159,6 +169,14 @@ class ZeroconfConnect:
159
169
  return self._TokenStorageDir
160
170
 
161
171
 
172
+ @property
173
+ def TokenStorageFile(self) -> str:
174
+ """
175
+ The filename and extension of the authorization token cache file.
176
+ """
177
+ return self._TokenStorageFile
178
+
179
+
162
180
  @property
163
181
  def Uri(self) -> str:
164
182
  """
@@ -677,6 +695,7 @@ class ZeroconfConnect:
677
695
  scope=SPOTIFY_SCOPES,
678
696
  clientId=SPOTIFY_DESKTOP_APP_CLIENT_ID,
679
697
  tokenStorageDir=self.TokenStorageDir,
698
+ tokenStorageFile=self.TokenStorageFile,
680
699
  tokenProviderId='SpotifyWebApiAuthCodePkce',
681
700
  tokenProfileId=loginId,
682
701
  )