fix: resolve governance gaps, patch credential exposure, and connect multi-platform dashboard
This commit is contained in:
1 parent
6f2e8e0c9d
commit
7fb7d775d8
5 files changed
+324
-387
No files matched your search
@@ -4,16 +4,28 @@ Direct diagnostic to test Spotify OAuth2 Client Credentials flow
|
||||
and probe endpoint permissions for Artist data, Top Tracks, and Search.
|
||||
"""
|
||||
|
||||
import os
|
||||
import requests
|
||||
import base64
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
|
||||
CLIENT_ID = os.getenv("SPOTIFY_CLIENT_ID", "a4a008ec790d45fba6a37315a1a3d847")
|
||||
CLIENT_SECRET = os.getenv("SPOTIFY_CLIENT_SECRET", "a5c67d9a63d340b6ae4a5bec83bca241")
|
||||
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
||||
if str(PROJECT_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
load_dotenv(PROJECT_ROOT / ".env")
|
||||
|
||||
CLIENT_ID = os.getenv("SPOTIFY_CLIENT_ID", "").strip()
|
||||
CLIENT_SECRET = os.getenv("SPOTIFY_CLIENT_SECRET", "").strip()
|
||||
|
||||
|
||||
def get_token(client_id: str, client_secret: str):
|
||||
"""Requests a bearer token via standard OAuth2 Client Credentials."""
|
||||
if not client_id or not client_secret:
|
||||
return 0, {"error": "SPOTIFY_CLIENT_ID or SPOTIFY_CLIENT_SECRET not configured"}
|
||||
|
||||
auth_header = base64.b64encode(f"{client_id}:{client_secret}".encode()).decode()
|
||||
url = "https://accounts.spotify.com/api/token"
|
||||
res = requests.post(
|
||||
@@ -50,6 +62,10 @@ if __name__ == "__main__":
|
||||
print("SPOTIFY API AUTHENTICATION & ENDPOINT PERMISSION DIAGNOSTIC")
|
||||
print("=" * 80)
|
||||
|
||||
if not CLIENT_ID or not CLIENT_SECRET:
|
||||
print("Error: Missing credentials in environment. Set SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET in .env.")
|
||||
sys.exit(1)
|
||||
|
||||
status, token_resp = get_token(CLIENT_ID, CLIENT_SECRET)
|
||||
print(f"Token Endpoint Status: {status}")
|
||||
|
||||
|
||||
Reference in new issue
Block a user