[GH-ISSUE #584] 500 internal error using PaaS, working fine on local #347

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

Originally created by @fullfine909 on GitHub (Oct 7, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/584

Hi!

I am developing a tool that takes songs of Youtube and creates a playlists in Spotify. I have run the application succesfully in local, but I get an error when I try it in Elastic Beanstalk, the PaaS of Amazon.

I am using a Flask server and the Spotipy python library. I think that the problem is related with the redirect_uri, but I have no idea of what I should do. I create two spotipy objects in my code. The first one, using Client Credentials Flow, works perfectly online. However, when I try to use another one with Authorization Code Flow, I get the error. I can even create it, but when I call to any function, even to search tracks, I get the 500 internal server error. I assume that the redirect_uri has to be the same url where the app is launched.

Thanks in advance!

Originally created by @fullfine909 on GitHub (Oct 7, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/584 Hi! I am developing a tool that takes songs of Youtube and creates a playlists in Spotify. I have run the application succesfully in local, but I get an error when I try it in Elastic Beanstalk, the PaaS of Amazon. I am using a Flask server and the Spotipy python library. I think that the problem is related with the redirect_uri, but I have no idea of what I should do. I create two spotipy objects in my code. The first one, using Client Credentials Flow, works perfectly online. However, when I try to use another one with Authorization Code Flow, I get the error. I can even create it, but when I call to any function, even to search tracks, I get the 500 internal server error. I assume that the redirect_uri has to be the same url where the app is launched. Thanks in advance!
kerem 2026-02-27 23:22:07 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner
<!-- gh-comment-id:705191867 --> @stephanebruckert commented on GitHub (Oct 7, 2020): Hi, does this help? https://github.com/plamere/spotipy/blob/master/FAQ.md#how-do-i-obtain-authorization-in-a-headlessbrowserless-environment
Author
Owner

@fullfine909 commented on GitHub (Oct 7, 2020):

Not really. I think that now it works locally because it has the token in the cache. Do you know how can I force to delete it?

<!-- gh-comment-id:705194581 --> @fullfine909 commented on GitHub (Oct 7, 2020): Not really. I think that now it works locally because it has the token in the cache. Do you know how can I force to delete it?
Author
Owner

@stephanebruckert commented on GitHub (Oct 7, 2020):

There should be a hidden file starting with .cache in your project folder. You can delete it using rm

<!-- gh-comment-id:705211185 --> @stephanebruckert commented on GitHub (Oct 7, 2020): There should be a hidden file starting with `.cache` in your project folder. You can delete it using `rm`
Author
Owner

@fullfine909 commented on GitHub (Oct 7, 2020):

Okay, I've gotten it to work in a bit of a "dirty" way. Calling SpotifyOAuth () I pass the variable cache_path = '. Mycache' to it, then I upload it to aws and it works, but I think this is just a temporary solution. I attach the link so you can see the work:
http://ys5-env.eba-mjmi37yf.eu-west-1.elasticbeanstalk.com/
Example videos that work:
https://www.youtube.com/watch?v=5lthiQoQiRA&t=2953s&ab_channel=H%C3%96RBERLIN
https://www.youtube.com/watch?v=4utKO75DtBE&t=637s&ab_channel=BE-AT.TV
You can click the title and you will find a playlist with all the songs, you can click a song and the spotify link will open, you can move the mouse over the covers and it will be heard.

<!-- gh-comment-id:705222595 --> @fullfine909 commented on GitHub (Oct 7, 2020): Okay, I've gotten it to work in a bit of a "dirty" way. Calling SpotifyOAuth () I pass the variable cache_path = '. Mycache' to it, then I upload it to aws and it works, but I think this is just a temporary solution. I attach the link so you can see the work: http://ys5-env.eba-mjmi37yf.eu-west-1.elasticbeanstalk.com/ Example videos that work: https://www.youtube.com/watch?v=5lthiQoQiRA&t=2953s&ab_channel=H%C3%96RBERLIN https://www.youtube.com/watch?v=4utKO75DtBE&t=637s&ab_channel=BE-AT.TV You can click the title and you will find a playlist with all the songs, you can click a song and the spotify link will open, you can move the mouse over the covers and it will be heard.
Author
Owner

@stephanebruckert commented on GitHub (Oct 25, 2020):

I pass the variable cache_path = '. Mycache' to it, then I upload it to aws and it works, but I think this is just a temporary solution

I think you are right, it's not a good solution and could be improved.

What I've been doing in my own app is to persist new tokens into a DB and then read from that DB every time I need the token. See github.com/resident-archive/resident-archive@a869b73f1f/functions/to-spotify/main.py (L129..L157)

I'm going to close your issue as you found a temporary solution, and the improvement above can be discussed here https://github.com/plamere/spotipy/issues/51

<!-- gh-comment-id:716143813 --> @stephanebruckert commented on GitHub (Oct 25, 2020): > I pass the variable cache_path = '. Mycache' to it, then I upload it to aws and it works, but I think this is just a temporary solution I think you are right, it's not a good solution and could be improved. What I've been doing in my own app is to persist new tokens into a DB and then read from that DB every time I need the token. See https://github.com/resident-archive/resident-archive/blob/a869b73f1f64538343be1604d43693b6165cc58a/functions/to-spotify/main.py#L129..L157 I'm going to close your issue as you found a temporary solution, and the improvement above can be discussed here https://github.com/plamere/spotipy/issues/51
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#347
No description provided.