mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #598] Avoid authentication every time I add song to library #355
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#355
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 @tejas-kale on GitHub (Oct 26, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/598
Hi. I want to write a Flask application that can add the currently playing song to my library. The aim is to have a Keyboard Maestro trigger that will go to the URL
http://localhost:5002/like_currently_playing_song. I am trying to address two problems:like_currently_playing_song, 2 browser tabs open and close (one foruser-read-currently-playingOAuth and the other foruser-library-modify, I guess). How can I avoid this behaviour? The intention behind writing this application is to like a song with a shortcut without having to change windows.http://localhost:5002/like_currently_playing_songin the background? With my current code, Safari comes into focus.Pardon me if this is not the right place to post the question. Thanks.
Here is my code:
@Peter-Schorn commented on GitHub (Oct 28, 2020):
@tejas-kale You're using the library wrong. Why did you create a separate instance of
Spotifyfor each request? You only need once instance per Spotify user.Furthermore, it looks like you're saving the authorization information for each instance of
Spotifyto the same file. These instances keep overwriting each other's authorization information and each instance is authorized for different scopes. This is why you have to keep logging in again.@tejas-kale commented on GitHub (Oct 28, 2020):
@Peter-Schorn Thanks for the clarification. I thought each
SpotifyOAuthaccepts a single scope so I created 2 instances. Changing the scope assignment toscope="user-read-currently-playing user-library-modify"got rid of the problem.
Pasting the corrected code just for reference: