Authentification de l'API Spotify dans Python
Spotify API Authentication in Python
# # # # # # # # # # # # # # # # # # # # # #
# Author: @Ashutosh_Rana #
# Github: Mindquaker #
# # # # # # # # # # # # # # # # # # # # # #
import requests
import os
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
AUTH_URL= "https://accounts.spotify.com/api/token" #url for authentication
clientID = os.getenv("CLIENT_ID") #client id from the spotify api
clientSecret = os.getenv("CLIENT_SECRET") #client secret from sptify api
#authentication request
auth_response = requests.post(AUTH_URL,
{ 'grant_type': 'client_credentials',
'client_id' :clientID,
'client_secret' : clientSecret,
}
)
auth_response_data = auth_response.json() #Respononse from the api
auth_token = auth_response_data["access_token"] #authentication token
header = { #authentication header for the get request
'Authorization': 'Bearer {token}'.format(token=auth_token)
}
mindquaker