[GH-ISSUE #1018] How can I send redirect uri to user and why my app is stuck #603

Closed
opened 2026-02-28 00:00:09 +03:00 by kerem · 1 comment
Owner

Originally created by @Vitek14 on GitHub (Aug 18, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1018

Hi, I'm trying to make a discord bot(disnake) with spotipy, but for most things i need redirect uri. I passed it, but when the user calls command with authorization, my bot stucks every time until log in. How can i remove freezes? And another question: How can user get link to authorize app?
Code:

    async def like_button(inter):
        # Creating *Bot thinking...* to avoid interaction stuck, where inter - interaction, when user press button
        await inter.response.defer()
        ...some_code
        sp = spotipy.Spotify(auth_manager=SpotifyOAuth(
            client_id=spotify_client,                               # From database
            client_secret=spotify_secret,                           # From database
            redirect_uri="http://localhost:8888/callback",
            scope="user-library-modify",
            cache_handler=spotipy.MemoryCacheHandler()
        ))
        sp.current_user_saved_tracks_add(tracks=current_tracks[0])  # Adding current track to favorites. STUCK ON THIS LINE
        await inter.followup.send("Success")
        ...some_code

I'm sorry if something is wrong in code

Originally created by @Vitek14 on GitHub (Aug 18, 2023). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1018 <!--- 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 ---> Hi, I'm trying to make a discord bot(disnake) with spotipy, but for most things i need redirect uri. I passed it, but when the user calls command with authorization, **my bot stucks every time until log in**. How can i remove freezes? And another question: How can user get link to authorize app? Code: ```python async def like_button(inter): # Creating *Bot thinking...* to avoid interaction stuck, where inter - interaction, when user press button await inter.response.defer() ...some_code sp = spotipy.Spotify(auth_manager=SpotifyOAuth( client_id=spotify_client, # From database client_secret=spotify_secret, # From database redirect_uri="http://localhost:8888/callback", scope="user-library-modify", cache_handler=spotipy.MemoryCacheHandler() )) sp.current_user_saved_tracks_add(tracks=current_tracks[0]) # Adding current track to favorites. STUCK ON THIS LINE await inter.followup.send("Success") ...some_code ``` I'm sorry if something is wrong in code
kerem 2026-02-28 00:00:09 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@Vitek14 commented on GitHub (Aug 20, 2023):

Solved! I did this using SpotifyOAuth().get_authorize_url()
I send the link to the user and write the token to the database

<!-- gh-comment-id:1685309983 --> @Vitek14 commented on GitHub (Aug 20, 2023): Solved! I did this using SpotifyOAuth().get_authorize_url() I send the link to the user and write the token to the database
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#603
No description provided.