Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Spotify API Authentication in 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) 

 }  
Comment

PREVIOUS NEXT
Code Example
Python :: pytorch dataloader 
Python :: python dataframe replace in all dataframe 
Python :: get median using python 
Python :: maximum element in dataframe row 
Python :: pickle save dict 
Python :: python print emoji 
Python :: vscode python multiline comment 
Python :: python - find columns that are objects 
Python :: flask dockerize 
Python :: hover show all Y values in Bokeh 
Python :: connect mongodb with python 
Python :: django data from many to many field in template 
Python :: Converting Dataframe from the multi-dimensional list with column name 
Python :: python *x 
Python :: selenium python find element by class name with space 
Python :: arithmetic in python 
Python :: convert 2d aray into 1d using python 
Python :: jupyter change cell to text 
Python :: numpy savetxt list of strings 
Python :: scrapy shell 
Python :: yield python 
Python :: python set timezone windows 
Python :: python import file from different directory 
Python :: spanish to english 
Python :: windows 10 python path 
Python :: defaultdict initialize keys 
Python :: datetime decreasing date python 
Python :: python index method 
Python :: discord.py setup_hook 
Python :: flatmap in python 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =