Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -43,13 +43,14 @@ def extract_track_id_from_url(url):
|
|
43 |
def app():
|
44 |
|
45 |
# Step 1: User Authorization
|
46 |
-
if st.session_state.get('code') is None:
|
47 |
auth_params = {
|
48 |
'client_id': CLIENT_ID,
|
49 |
'response_type': 'code',
|
50 |
'redirect_uri': REDIRECT_URI,
|
51 |
'scope': 'user-read-private', # Modify as per your required scopes
|
52 |
}
|
|
|
53 |
st.write('Please log in to Spotify')
|
54 |
st.markdown(f"[Log In]({AUTH_URL}?{urlencode(auth_params)})", unsafe_allow_html=True)
|
55 |
else:#
|
@@ -131,8 +132,7 @@ def app():
|
|
131 |
|
132 |
|
133 |
if 'code' not in st.session_state:
|
134 |
-
|
135 |
-
|
136 |
-
st.session_state['code'] = query_params.get('code', [None])[0]
|
137 |
|
138 |
app()
|
|
|
43 |
def app():
|
44 |
|
45 |
# Step 1: User Authorization
|
46 |
+
if st.session_state.get('code') is None or st.session_state.get('reset') == 1:
|
47 |
auth_params = {
|
48 |
'client_id': CLIENT_ID,
|
49 |
'response_type': 'code',
|
50 |
'redirect_uri': REDIRECT_URI,
|
51 |
'scope': 'user-read-private', # Modify as per your required scopes
|
52 |
}
|
53 |
+
st.session_state['reset'] = 0
|
54 |
st.write('Please log in to Spotify')
|
55 |
st.markdown(f"[Log In]({AUTH_URL}?{urlencode(auth_params)})", unsafe_allow_html=True)
|
56 |
else:#
|
|
|
132 |
|
133 |
|
134 |
if 'code' not in st.session_state:
|
135 |
+
query_params = st.experimental_get_query_params()
|
136 |
+
st.session_state['code'] = query_params.get('code', [None])[0]
|
|
|
137 |
|
138 |
app()
|