Skip to content

Commit

Permalink
add unique_hash to CacheFileHandler and SpotifyOAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
dieser-niko authored Jul 26, 2024
1 parent 185140a commit 723b8f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions spotipy/cache_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class CacheFileHandler(CacheHandler):

def __init__(self,
cache_path=None,
unique_hash=None,
username=None,
encoder_cls=None):
"""
Expand All @@ -67,6 +68,8 @@ def __init__(self,
self.cache_path = cache_path
else:
cache_path = ".cache"
if unique_hash:
cache_path += "-" + str(unique_hash)
username = (username or os.getenv(CLIENT_CREDS_ENV_VARS["client_username"]))
if username:
cache_path += "-" + str(username)
Expand Down
4 changes: 3 additions & 1 deletion spotipy/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import time
import warnings
import webbrowser
import hashlib

import requests
import urllib.parse as urllibparse
Expand Down Expand Up @@ -349,8 +350,9 @@ def __init__(
else:
username = (username or os.getenv(CLIENT_CREDS_ENV_VARS["client_username"]))
self.cache_handler = CacheFileHandler(
unique_hash=hashlib.sha256(client_secret.encode('utf-8')).hexdigest()[:7],
username=username,
cache_path=cache_path
cache_path=cache_path,
)
self.proxies = proxies
self.requests_timeout = requests_timeout
Expand Down

0 comments on commit 723b8f1

Please sign in to comment.