mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #618] cache problem #368
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#368
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Sticks111 on GitHub (Nov 26, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/618
In the Spotipy / flask example, after implementing the steps and upon clicking on "Sign In," I was led to the Spotify API authorization page. Upon clicking accept, I received in my terminal a "cannot read cache" message. A few hours later, when I tried to reconnect again, I could no longer click beyond the Sign in page -- I wasn't able to reach to the Spotify API auth. pg. this time -- as soon as I clicked "Sign In," a "cannot read cache" message popped up right away.
Would appreciate any thoughts or suggestions.
Thanks very much
@Sticks111 commented on GitHub (Nov 26, 2020):
Sorry, okay, I was able to connect again to the Spotify Authorization page after clicking on Sign in (I wasn't able to earlier because I left off the / in export SPOTIPY_REDIRECT_URI='http://127.0.0.1:5000/callback/)
However, upon clicking Agree (in the Agree/Cancel section of the "You agree that the app will be able to...View your Spotify account data...View your activity on Spotify...Take actions in Spotify on your behalf..." page) , I am still receiving a "Couldn't read cache at: ./.spotify_caches/....- - [26/Nov/2020 23:19:43] "GET / HTTP/1.0" 200 -" message in the terminal.
Would be appreciate any suggestions!
Thanks so much
@Peter-Schorn commented on GitHub (Nov 26, 2020):
Did you check to see if a cache file exists at the specified path? If you are running the app for the first time then it should be expected that the cache path doesn't exist and you can ignore this message.
Also it would be helpful if you posted some of your code.
@Sticks111 commented on GitHub (Nov 26, 2020):
Thanks Peter!
I have a .spotify_caches/ folder, though it appears to contain no files. On the other hand, in the .flask_session/ folder, a new file is automatically created with every new flask run. The folders that are present are there after I used the same code as in the example, though adding an additional port option at the end and using a slightly different command in the terminal, also copied below:
if name == 'main':
app.run(threaded=True, port=int(os.environ.get("PORT", 8080)))
if name == 'main':
app.run(threaded=True, port=int(os.environ.get("PORT", 5000)))
$ pip3 install spotipy Flask Flask-Session
$ export SPOTIPY_CLIENT_ID=CLIENT_ID
$ export SPOTIPY_CLIENT_SECRET=SECRET
$ export SPOTIPY_REDIRECT_URI='http://127.0.0.1:5000/callback/'
$ flask run
A quick note also that in Spotify for Developers/Dashboard/Edit Settings/Redirect URIs, I have saved the following Redirect URIs:
http://127.0.0.1:8080/callback/
http://127.0.0.1:5000/callback/
Am wondering if there is something that I should be adding in order to successfully connect to the API? Sorry, I think that I have followed the initial connection instructions closely but I am quite new to this and am wondering if there's an obvious missing piece that I have overlooked.
Thanks so much!
@Peter-Schorn commented on GitHub (Nov 27, 2020):
Are you using the code from examples/app.py unmodified? If not, please post the actual code for your app. Also what exact path that is printed when you get the error message stating that the cache couldn't be read?
This is very confusing to me. Did you copy this line directly from your console or did you edit it before posting it here?
@Sticks111 commented on GitHub (Nov 27, 2020):
Sorry the entire path that appears on my console unabridged after $ flask run is copied below.
Am using the exact code from examples/app.py except for some of the Prerequisites, where instead of python3 -m flask run --port=8080 I use just flask run and instead of export SPOTIPY_REDIRECT_URI='http://127.0.0.1:8080' I use export SPOTIPY_REDIRECT_URI='http://127.0.0.1:5000/callback' (have saved 'http://127.0.0.1:5000/callback' in https://developer.spotify.com/dashboard/applications).
Couldn't read cache at: ./.spotify_caches/9cf8b13f-91bf-4e02-b72c-b52733e03926
192.168.195.36 - - [26/Nov/2020 23:16:37] "GET / HTTP/1.0" 200 -
Couldn't read cache at: ./.spotify_caches/9cf8b13f-91bf-4e02-b72c-b52733e03926
192.168.153.58 - - [26/Nov/2020 23:19:43] "GET / HTTP/1.0" 200 -
@Peter-Schorn commented on GitHub (Nov 27, 2020):
So the full cache path is
with the line break?
@Sticks111 commented on GitHub (Nov 27, 2020):
Sorry the full cache path which includes line breaks is as follows (for some reason not everything showed up in my earlier response):
./.spotify_caches/9cf8b13f-91bf-4e02-b72c-b52733e03926
192.168.195.36 - - [26/Nov/2020 23:16:37] "GET / HTTP/1.0" 200 -
Couldn't read cache at: ./.spotify_caches/9cf8b13f-91bf-4e02-b72c-b52733e03926
192.168.153.58 - - [26/Nov/2020 23:19:43] "GET / HTTP/1.0" 200 -
192.168.83.137 - - [27/Nov/2020 00:43:20] "GET /:8080/ HTTP/1.0" 404 -
Couldn't read cache at: ./.spotify_caches/101b04c2-fc97-4f30-8af7-3e7d6d268582
192.168.74.236 - - [27/Nov/2020 00:43:21] "GET / HTTP/1.0" 200 -
Couldn't read cache at: ./.spotify_caches/f577f9b6-ce4c-4a69-a606-4b1ed40674a9
192.168.162.241 - - [27/Nov/2020 00:43:21] "GET / HTTP/1.0" 200 -
192.168.74.236 - - [27/Nov/2020 00:43:24] "GET /:8080/ HTTP/1.0" 404 -
Couldn't read cache at: ./.spotify_caches/7d45b808-d93a-4bea-9736-177be4430b51
192.168.115.65 - - [27/Nov/2020 00:48:01] "HEAD / HTTP/1.0" 200 -
@Peter-Schorn commented on GitHub (Nov 27, 2020):
No, the full cache path is
The other lines are different messages that are separate from the cache path. Also, when pasting code into a comment, please use code fences.
Unless you have modified
app.py, the redirect URI should be the same as the URL that the server is running on. Based on this console output:Your redirect URI needs to be
https://5baccc80-dda9-489c-8763-342a8ef72bbc-ide.cs50.xyz:8080/.Now, after the user logs in and clicks agree, the
indexfunction will be called because it is annotated with@app.route('/')@Peter-Schorn commented on GitHub (Nov 27, 2020):
Why did you use
http://127.0.0.1:5000/callbackfor the redirect URI? There is no function that handles the/callbackroute.@Sticks111 commented on GitHub (Nov 27, 2020):
Thanks for pointing that out! Have removed all the callbacks.
I've run another flask session and have successfully reached the Spotify API authorization page.
Upon hitting accept, am now experiencing a shorter message than before:
./.spotify_caches/38a3d5d3-e157-47d2-940a-18c70c3ab5b3
192.168.153.58 - - [27/Nov/2020 03:54:09] "GET / HTTP/1.0" 200 -
192.168.153.58 - - [27/Nov/2020 03:54:09] "GET /favicon.ico HTTP/1.0" 404 -
Not sure why this message is popping up
@Peter-Schorn commented on GitHub (Nov 27, 2020):
192.168.153.58 - - [27/Nov/2020 03:54:09] "GET / HTTP/1.0" 200 -is a log message describing the webpage that a user opened. I'm not sure about the other message that contains the path of the cache file. Is the app working though?@Sticks111 commented on GitHub (Nov 27, 2020):
The 200 message definitely sounds promising, looks like I’m making progress. I’m not entirely sure if the app is working as intended; I feel I may still be missing something as I am not able to see anything just yet aside from the Sign in page and the authorization page upon clicking the Sign In link. What should I be seeing if the app is working?
@Peter-Schorn commented on GitHub (Nov 27, 2020):
You should see this after you sign in.
@Sticks111 commented on GitHub (Nov 27, 2020):
Ah got it, thanks very much! Will continue working on this, hope I’ll be able to see a menu like this soon!
@Peter-Schorn commented on GitHub (Nov 27, 2020):
What are you seeing after you finish signing in? Send a picture.
@Sticks111 commented on GitHub (Nov 27, 2020):
Have attached here screenshots of the page with the Sign in link and the page that shows up after I click on that Sign in link:
screenshots.docx
@Peter-Schorn commented on GitHub (Nov 27, 2020):
What page are you redirected to after you sign in? You should be redirected to the page in the image that I sent.
@Sticks111 commented on GitHub (Nov 27, 2020):
The page that I am redirected to immediately upon signing in is a Spotify page asking me to agree to some terms. Here is a screenshot of that:
screenshot.docx
Am not seeing the page that I should be seeing in the image that you had sent
@Peter-Schorn commented on GitHub (Nov 27, 2020):
WHAT PAGE ARE YOU REDIRECTED TO AFTER YOU SIGN IN TO SPOTIFY AND CLICK AGREE
@Sticks111 commented on GitHub (Nov 27, 2020):
Am seeing this page after clicking agree:
This site can’t be reached
127.0.0.1 refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
Reload
Details
@Peter-Schorn commented on GitHub (Nov 27, 2020):
When you start the server, you will get a message saying
This URL must be the exact same as your redirect URI.
@Peter-Schorn commented on GitHub (Nov 27, 2020):
Here's what you should do: At the very bottom of the
app.pyfile, replacewith
Then change your redirect URI to
http://localhost:8080/. Don't forget to add it in the Spotify developer dashboard.Next, run the app from your terminal using
python3 path/to/app.py.@Sticks111 commented on GitHub (Nov 27, 2020):
Thanks so much! Really appreciate the guidance.
Just have a follow up question regarding the final step. After running python3 path/to/app.py in the terminal, I get the message:
python3: can't open file 'path/to/app.py': [Errno 2] No such file or directory
The file name is definitely app.py, so am wondering why I might be receiving this message in the terminal?
@Sticks111 commented on GitHub (Nov 27, 2020):
Good morning Peter and @stephanebruckert, have been trying different variations of python3 path/to/app.py; for instance copying special the path of app.py in my directory and using that in place of path in python3 path/to/app.py.
When I use python3 path/to/app.py, the terminal produces the message:
python3: can't open file 'path/to/app.py': [Errno 2] No such file or directory.
And when I use one of my variations such as the one above, I am redirected to this page:
This page isn’t working
5baccc80-dda9-489c-8763-342a8ef72bbc-ide.cs50.xyz didn’t send any data.
ERR_EMPTY_RESPONSE
Am wondering why this might be happening?
Thanks so much
@Peter-Schorn commented on GitHub (Nov 27, 2020):
What operating system are you using? Enclose the file path in quotes.
@Sticks111 commented on GitHub (Nov 27, 2020):
am using the Windows 10
For some reason after enclosing the file path in quotes am still being redirected to:
This page isn’t working5baccc80-dda9-489c-8763-342a8ef72bbc-ide.cs50.xyz didn’t send any data.
ERR_EMPTY_RESPONSE
@Peter-Schorn commented on GitHub (Nov 27, 2020):
Did you ensure that the redirect URI is the same as the address that the flask server is running on?
@Sticks111 commented on GitHub (Nov 27, 2020):
I believe so; after I used:
at the end of app.py, I made sure to also add http://localhost:8080/ into my Spotify dashboard; and my terminal has been producing the following: Running on http://localhost:8080/
@Peter-Schorn commented on GitHub (Nov 27, 2020):
Did you change the redirect uri in the environment variables to be
http://localhost:8080/?@Sticks111 commented on GitHub (Nov 27, 2020):
Yep, I have been using $ export SPOTIPY_REDIRECT_URI='http://localhost:8080/'
@Peter-Schorn commented on GitHub (Nov 27, 2020):
What is the URL of the page that you are redirected to after you sign in to your Spotify account and click agree.
@Sticks111 commented on GitHub (Nov 27, 2020):
The URL is:
http://localhost:8080/?code=AQBpSL9wFDTPb5y0ZPRF91lFbcv0F-QQHQxyRnOJ-yrAblpfYETIeB5D6WA1ke-gZECaL0FHNBpGKYeV8GJhj-qTscovQXTUEZEF34pcAvDQYhJb4NuImQgP_-F-jmV8L68N6ePTON9qBJNRE0dFE66taWk7P-wxdgEnbc97w3J-Ic8XlEpTWHmOR0_p4Y634pbZJY6-U-lVG4z_IsKNuAsNOAxyTZdSLsd4TxLYPOo
@Peter-Schorn commented on GitHub (Nov 27, 2020):
Well then I don't know why it doesn't work
@Sticks111 commented on GitHub (Nov 27, 2020):
Thanks Peter! Will keep working on it and hopefully there will be a breakthrough
A quick question; this part right here; is this exactly how this should be typed into the terminal?:
python3 -m flask run --port=8080
Just now I also added inbound and outbound rules to my firewall to allow access to port 5000. Not sure that helped though.
@dieser-niko commented on GitHub (Aug 28, 2024):
I'm going to close this issue as it seems to be outdated. Please reopen if the issue still persists.