diff options
| author | Fuwn <[email protected]> | 2023-01-02 21:08:35 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-01-02 21:08:35 -0800 |
| commit | 863ceb87dd297022b98a57f881a3b98692c8231a (patch) | |
| tree | 365bf97e7afd7b4a2df786e763f20e420603e059 | |
| parent | fix(spotify.py): headers (diff) | |
| download | rubys_song_skipper-863ceb87dd297022b98a57f881a3b98692c8231a.tar.xz rubys_song_skipper-863ceb87dd297022b98a57f881a3b98692c8231a.zip | |
fix(spotify.py): headers
| -rw-r--r-- | rubys_song_skipper/bot.py | 20 | ||||
| -rw-r--r-- | rubys_song_skipper/spotify.py | 12 |
2 files changed, 11 insertions, 21 deletions
diff --git a/rubys_song_skipper/bot.py b/rubys_song_skipper/bot.py index 382320f..06590e9 100644 --- a/rubys_song_skipper/bot.py +++ b/rubys_song_skipper/bot.py @@ -24,21 +24,17 @@ class Bot(commands.Bot): with open("code.txt", "r") as file: code = file.read() - print("code is '" + code + "'") - if code == "": - await ctx.send("no code, sign in") + await ctx.send("no authorization found, please sign in ~uwu~") else: - print( - requests.post( - "https://api.spotify.com/v1/me/player/next", - headers={ - "Authorization": "Bearer " + code, - "Content-Type": "application/json", - }, - ).json() + requests.post( + "https://api.spotify.com/v1/me/player/next", + headers={ + "Authorization": "Bearer " + code, + "Content-Type": "application/json", + }, ) - await ctx.send("skipped lol") + await ctx.send("i've skipped that song ~uwu~") file.close() diff --git a/rubys_song_skipper/spotify.py b/rubys_song_skipper/spotify.py index 57535d5..19f8d6b 100644 --- a/rubys_song_skipper/spotify.py +++ b/rubys_song_skipper/spotify.py @@ -5,19 +5,15 @@ import base64 CLIENT_ID = "3b278200b722431488a0e70111700211" CLIENT_SECRET = "0689cf819adb442a9abddce154f58cad" -AUTHORIZATION = "M2IyNzgyMDBiNzIyNDMxNDg4YTBlNzAxMTE3MDAyMTE6MDY4OWNmODE5YWRiNDQyYTlhYmRkY2UxNTRmNThjYWQ=" +# AUTHORIZATION = "M2IyNzgyMDBiNzIyNDMxNDg4YTBlNzAxMTE3MDAyMTE6MDY4OWNmODE5YWRiNDQyYTlhYmRkY2UxNTRmNThjYWQ=" def bearer(code): authorization = requests.post( "https://accounts.spotify.com/api/token", - # data={ - # "grant_type": "client_credentials", - # "client_id": CLIENT_ID, - # "client_secret": CLIENT_SECRET, - # }, headers={ - "Authorization": f"Basic {AUTHORIZATION}", + # "Authorization": f"Basic {AUTHORIZATION}", + "Authorization": f"Basic {base64.urlsafe_b64encode(f'{CLIENT_ID}:{CLIENT_SECRET}'.encode()).decode()}", "Accept": "application/json", "Content-Type": "application/x-www-form-urlencoded", }, @@ -28,8 +24,6 @@ def bearer(code): }, ) - print(authorization.text) - if authorization.status_code == 200: json = authorization.json() |