[GH-ISSUE #721] Spotipy | Can't see the url needed for token #435

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

Originally created by @Eyfelix on GitHub (Aug 30, 2021).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/721

I want to make my python script run 24/7 in a serveur cause it scrap Spotify info.

I created a serveur, put my python script on it, I can run it using Putty but it cant show me the url or redirect me to the url for the token (see screenshot ).
My project work fine on my computer and I've made a simplify version.
I've also an error about missing cache file but it dont seem important.

image
What I get when I run my script.

image
When I press q.

image
Here, they ask me for the url that I don't have.

image
When I enter a wrong url or nothing

import spotipy
from spotipy.oauth2 import SpotifyOAuth
import os
from  pprint import pprint

##define os variables
os.environ["SPOTIPY_CLIENT_ID"]="client id"
os.environ["SPOTIPY_CLIENT_SECRET"]="client secret"
os.environ["SPOTIPY_REDIRECT_URI"]="localhost:8080"

scope="user-read-recently-played"

sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))


historique=sp.current_user_recently_played(limit=50,after=None,before=None) #!THIS LINE BUG
pprint(historique)

My code simplifed

Thanks for your help

(ps : it's the first time I post on github)

Originally created by @Eyfelix on GitHub (Aug 30, 2021). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/721 <!--- Please make sure you've: - read the FAQ https://github.com/plamere/spotipy/blob/master/FAQ.md - read the documentation https://spotipy.readthedocs.io/en/latest/ - searched older issues If your question is about code, please share the code you are using ---> I want to make my python script run 24/7 in a serveur cause it scrap Spotify info. I created a serveur, put my python script on it, I can run it using Putty but it cant show me the url or redirect me to the url for the token (see screenshot ). My project work fine on my computer and I've made a simplify version. I've also an error about missing cache file but it dont seem important. ![image](https://user-images.githubusercontent.com/79328482/131328713-dce7315b-2527-4912-b59a-f63c71b15c81.png) What I get when I run my script. ![image](https://user-images.githubusercontent.com/79328482/131328896-6805a338-6221-47ae-a924-a14bcc77ee9d.png) When I press q. ![image](https://user-images.githubusercontent.com/79328482/131329002-868ee5e6-5fb6-4eca-8f01-742a6f127bf7.png) Here, they ask me for the url that I don't have. ![image](https://user-images.githubusercontent.com/79328482/131329125-84988cc7-c393-473c-a328-f36f3bd0fcae.png) When I enter a wrong url or nothing ``` import spotipy from spotipy.oauth2 import SpotifyOAuth import os from pprint import pprint ##define os variables os.environ["SPOTIPY_CLIENT_ID"]="client id" os.environ["SPOTIPY_CLIENT_SECRET"]="client secret" os.environ["SPOTIPY_REDIRECT_URI"]="localhost:8080" scope="user-read-recently-played" sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope)) historique=sp.current_user_recently_played(limit=50,after=None,before=None) #!THIS LINE BUG pprint(historique) ``` My code simplifed Thanks for your help (ps : it's the first time I post on github)
kerem 2026-02-27 23:22:37 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@Peter-Schorn commented on GitHub (Aug 30, 2021):

Never publicly share your client secret. Go to the Spotify dashboard and change it immediately. Also, please don't post screenshots of your code; post it as text.

<!-- gh-comment-id:908259152 --> @Peter-Schorn commented on GitHub (Aug 30, 2021): Never publicly share your client secret. Go to the Spotify dashboard and change it immediately. Also, please don't post screenshots of your code; post it as text.
Author
Owner

@stephanebruckert commented on GitHub (Aug 30, 2021):

Usually above "Enter the URL..." there should be a link that you can copy from the program output to a browser on a different machine. Here I can't see anything and something tells me that your environment is only displaying the last line. Can you try and see if there are other logs that you didn't copy here?

<!-- gh-comment-id:908624468 --> @stephanebruckert commented on GitHub (Aug 30, 2021): Usually above "Enter the URL..." there should be a link that you can copy from the program output _to_ a browser on a different machine. Here I can't see anything and something tells me that your environment is only displaying the last line. Can you try and see if there are other logs that you didn't copy here?
Author
Owner

@stephanebruckert commented on GitHub (Aug 30, 2021):

Ha I think I know, since you are in a headless browser (no UI), you need to set open_browser=False, as in this example:

github.com/plamere/spotipy@87fe473672/examples/headless.py (L6)

This is explained here in the FAQ https://github.com/plamere/spotipy/blob/master/FAQ.md#how-do-i-obtain-authorization-in-a-headlessbrowserless-environment

<!-- gh-comment-id:908631319 --> @stephanebruckert commented on GitHub (Aug 30, 2021): Ha I think I know, since you are in a headless browser (no UI), you need to set `open_browser=False`, as in this example: https://github.com/plamere/spotipy/blob/87fe473672be5d61491dcb159c6dd9ec74b1ba85/examples/headless.py#L6 This is explained here in the FAQ https://github.com/plamere/spotipy/blob/master/FAQ.md#how-do-i-obtain-authorization-in-a-headlessbrowserless-environment
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#435
No description provided.