[GH-ISSUE #545] Using app.py in the Examples Directory cause problem. #326

Closed
opened 2026-02-27 23:22:01 +03:00 by kerem · 2 comments
Owner

Originally created by @AbhayAysola on GitHub (Jul 23, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/545

Describe the bug
I used SET SPOTIPY_REDIRECT_URI=http://localhost:8888/
And I also set the same uri in the developer dashboard settings with no discrepancies.
The port of my flask app is 8888.
When I run my code and open the uri http://127.0.0.1:8888/ the sign in button is visible.
But when I click on the button it opens the Spotify Auth uri in another tab and the tab does not fully load. It opens another Spotify Auth tab again and again until I shut down the server.
I expect this to be a problem on my part as I am new to Oauth2 but I've been searching for a fix with no avail.

Your code
My code is the same as the app.py with an adjustment. The client id, secret and the redirect url are ENV variables.
I added this line to the end
if __name__ == '__main__': app.run(port=8888)

At the time of running I wouldn't know the username of the user and I am unsure of how to implement a cache system so I set
check_cache=False in the oauth2.py file.

Expected behavior
The normal auth procedure.

Output

app.py:30: DeprecationWarning: You're using 'as_dict = True'.get_access_token will return the token string directly in future versions. Please adjust your code accordingly, or use get_cached_token instead.
  session['token_info'] = auth_manager.get_access_token(request.args["code"])
127.0.0.1 - - [23/Jul/2020 20:15:39] 
"GET /?code=AQAnSKPxqyHvpdK_UJgOjKEraRhhzZPNZF02Mq5yYiNdU5ZBUW4QCmKYnYJJdkHoFjeZsqDLH6xeZQ2aWm19bUejbMwK2a0WkVM
KwLefOOdAjIgLQdFju1ScvmuZi5g_7arCMzUMqoMsni7viYC9mwD3lJ9wSurY-ss HTTP/1.1" 302 -
127.0.0.1 - - [23/Jul/2020 20:15:41] "GET /?code=AQA5oN_dEbfoa2k4wNZGoGFYyDpB4cA8pNwE8-Pskp-0qb4cnD5hWhXnN4oCItaSxGSs_gEspuWnF3h79rDMwxwZ3WRqK3KEVcz
WdCbk_Rq4A6MnIoHTiXytbtC9gXnwKNj2sotu0lGhaZRmbjlR2byTduJTqnPr6v8 HTTP/1.1" 302 -```

**Environment:**
 - OS: Windows
 - Python version-3.8.3
 - spotipy version-2.13.0
 - VSCode


Originally created by @AbhayAysola on GitHub (Jul 23, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/545 **Describe the bug** I used `SET SPOTIPY_REDIRECT_URI=http://localhost:8888/` And I also set the same uri in the developer dashboard settings with no discrepancies. The port of my flask app is 8888. When I run my code and open the uri `http://127.0.0.1:8888/` the sign in button is visible. But when I click on the button it opens the Spotify Auth uri in another tab and the tab does not fully load. It opens another Spotify Auth tab again and again until I shut down the server. I expect this to be a problem on my part as I am new to Oauth2 but I've been searching for a fix with no avail. **Your code** My code is the same as the app.py with an adjustment. The client id, secret and the redirect url are ENV variables. I added this line to the end ``if __name__ == '__main__': app.run(port=8888)`` At the time of running I wouldn't know the username of the user and I am unsure of how to implement a cache system so I set `check_cache=False` in the `oauth2.py` file. **Expected behavior** The normal auth procedure. **Output** ```"GET / HTTP/1.1" 200 - app.py:30: DeprecationWarning: You're using 'as_dict = True'.get_access_token will return the token string directly in future versions. Please adjust your code accordingly, or use get_cached_token instead. session['token_info'] = auth_manager.get_access_token(request.args["code"]) 127.0.0.1 - - [23/Jul/2020 20:15:39] "GET /?code=AQAnSKPxqyHvpdK_UJgOjKEraRhhzZPNZF02Mq5yYiNdU5ZBUW4QCmKYnYJJdkHoFjeZsqDLH6xeZQ2aWm19bUejbMwK2a0WkVM KwLefOOdAjIgLQdFju1ScvmuZi5g_7arCMzUMqoMsni7viYC9mwD3lJ9wSurY-ss HTTP/1.1" 302 - 127.0.0.1 - - [23/Jul/2020 20:15:41] "GET /?code=AQA5oN_dEbfoa2k4wNZGoGFYyDpB4cA8pNwE8-Pskp-0qb4cnD5hWhXnN4oCItaSxGSs_gEspuWnF3h79rDMwxwZ3WRqK3KEVcz WdCbk_Rq4A6MnIoHTiXytbtC9gXnwKNj2sotu0lGhaZRmbjlR2byTduJTqnPr6v8 HTTP/1.1" 302 -``` **Environment:** - OS: Windows - Python version-3.8.3 - spotipy version-2.13.0 - VSCode
kerem 2026-02-27 23:22:01 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@stephanebruckert commented on GitHub (Jul 23, 2020):

@AbhayAysola we should be merging a fix for that soon, but you can already use the code that is there https://github.com/plamere/spotipy/pull/539

<!-- gh-comment-id:663228110 --> @stephanebruckert commented on GitHub (Jul 23, 2020): @AbhayAysola we should be merging a fix for that soon, but you can already use the code that is there https://github.com/plamere/spotipy/pull/539
Author
Owner

@AbhayAysola commented on GitHub (Jul 24, 2020):

Thank you. It worked perfectly. I'm glad it's not a rookie mistake from my side.

<!-- gh-comment-id:663322410 --> @AbhayAysola commented on GitHub (Jul 24, 2020): Thank you. It worked perfectly. I'm glad it's not a rookie mistake from my side.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#326
No description provided.