-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_refresh_token.py
More file actions
24 lines (18 loc) · 668 Bytes
/
get_refresh_token.py
File metadata and controls
24 lines (18 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
from spotipy.oauth2 import SpotifyOAuth
# Spotify Part :
client_id = "Paste your spotify client_id here as a string"
client_secret = "Paste your spotify client_secret here as a string"
sp_oauth = SpotifyOAuth(
client_id=client_id,
client_secret=client_secret,
redirect_uri="http://127.0.0.1:8080/callback",
scope="user-read-recently-played",
cache_path="token.txt", # Path to store the token
)
token = sp_oauth.get_access_token()
refresh_token = token["refresh_token"]
print("\n\nPlease copy your refresh_token somewhere safe : \n\n")
print(refresh_token)
with open("refresh_token.txt", "w") as file:
file.write(refresh_token)