fix auth
This commit is contained in:
parent
88271a4b56
commit
14ee7ef987
24
src/main.py
24
src/main.py
@ -37,16 +37,6 @@ def get_auth():
|
|||||||
})
|
})
|
||||||
redirect = requests.get(f"https://accounts.spotify.com/authorize?{query}")
|
redirect = requests.get(f"https://accounts.spotify.com/authorize?{query}")
|
||||||
print(redirect.url)
|
print(redirect.url)
|
||||||
code = input('Enter code: ')
|
|
||||||
data = requests.post('https://accounts.spotify.com/api/token', data={
|
|
||||||
'grant_type': 'authorization_code',
|
|
||||||
'code': code,
|
|
||||||
'redirect_uri': os.getenv('REDIRECT_URI'),
|
|
||||||
}, headers={
|
|
||||||
'content-type': 'application/x-www-form-urlencoded',
|
|
||||||
'Authorization': 'Basic ' + base64.b64encode(f"{os.getenv('CLIENT_ID')}:{os.getenv('CLIENT_SECRET')}".encode()).decode()
|
|
||||||
}).json()
|
|
||||||
save_cache(data)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def update_token():
|
def update_token():
|
||||||
@ -64,6 +54,20 @@ def update_token():
|
|||||||
|
|
||||||
# Routes
|
# Routes
|
||||||
|
|
||||||
|
@app.route('/api/auth', methods=['GET'])
|
||||||
|
def auth():
|
||||||
|
code = request.args.get('code')
|
||||||
|
data = requests.post('https://accounts.spotify.com/api/token', data={
|
||||||
|
'grant_type': 'authorization_code',
|
||||||
|
'code': code,
|
||||||
|
'redirect_uri': os.getenv('REDIRECT_URI'),
|
||||||
|
}, headers={
|
||||||
|
'content-type': 'application/x-www-form-urlencoded',
|
||||||
|
'Authorization': 'Basic ' + base64.b64encode(f"{os.getenv('CLIENT_ID')}:{os.getenv('CLIENT_SECRET')}".encode()).decode()
|
||||||
|
}).json()
|
||||||
|
save_cache(data)
|
||||||
|
return "Authenticated"
|
||||||
|
|
||||||
@app.route('/api/nowplaying', methods=['GET'])
|
@app.route('/api/nowplaying', methods=['GET'])
|
||||||
def nowplaying():
|
def nowplaying():
|
||||||
cache = get_cache()
|
cache = get_cache()
|
||||||
|
Loading…
Reference in New Issue
Block a user