Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -42,17 +42,7 @@ def extract_track_id_from_url(url):
|
|
42 |
|
43 |
def app():
|
44 |
|
45 |
-
|
46 |
-
# Step 1: User Authorization
|
47 |
-
if st.session_state.get('code') is None or ('access_token' not in st.session_state or st.session_state['access_token'] is None):
|
48 |
-
auth_params = {
|
49 |
-
'client_id': CLIENT_ID,
|
50 |
-
'response_type': 'code',
|
51 |
-
'redirect_uri': REDIRECT_URI,
|
52 |
-
'scope': 'user-read-private', # Modify as per your required scopes
|
53 |
-
}
|
54 |
-
st.write('Please log in to Spotify')
|
55 |
-
st.markdown(f"[Log In]({AUTH_URL}?{urlencode(auth_params)})", unsafe_allow_html=True)
|
56 |
auth_code = st.session_state['code']
|
57 |
token_data = {
|
58 |
'grant_type': 'authorization_code',
|
@@ -64,6 +54,16 @@ def app():
|
|
64 |
token_r = requests.post(TOKEN_URL, data=token_data)
|
65 |
token_response = token_r.json()
|
66 |
st.session_state['access_token'] = token_response.get('access_token')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
else:#
|
68 |
if 'access_token' in st.session_state:
|
69 |
st.write("Enter a Spotify Track URL or URI to get its audio features.")
|
|
|
42 |
|
43 |
def app():
|
44 |
|
45 |
+
if st.session_state.get('code') is not None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
auth_code = st.session_state['code']
|
47 |
token_data = {
|
48 |
'grant_type': 'authorization_code',
|
|
|
54 |
token_r = requests.post(TOKEN_URL, data=token_data)
|
55 |
token_response = token_r.json()
|
56 |
st.session_state['access_token'] = token_response.get('access_token')
|
57 |
+
# Step 1: User Authorization
|
58 |
+
if st.session_state.get('code') is None or ('access_token' not in st.session_state or st.session_state['access_token'] is None):
|
59 |
+
auth_params = {
|
60 |
+
'client_id': CLIENT_ID,
|
61 |
+
'response_type': 'code',
|
62 |
+
'redirect_uri': REDIRECT_URI,
|
63 |
+
'scope': 'user-read-private', # Modify as per your required scopes
|
64 |
+
}
|
65 |
+
st.write('Please log in to Spotify')
|
66 |
+
st.markdown(f"[Log In]({AUTH_URL}?{urlencode(auth_params)})", unsafe_allow_html=True)
|
67 |
else:#
|
68 |
if 'access_token' in st.session_state:
|
69 |
st.write("Enter a Spotify Track URL or URI to get its audio features.")
|