mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #287] Best way to use Spotify inside an API? #160
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#160
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 @Jeoffreybauvin on GitHub (May 10, 2018).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/287
Hi,
I'm using Spotipy in a Flask API (full rest). I'm trying to use util.prompt_for_user_token for login, and it's working.
But now, I want to create an entrypoint /authenticate, which send me back the URL that util.prompt_for_user_token is trying to open in my browser.
I don't see any information in the documentation to do so. Can I catch this URL without opening my browser ?
@MaZderMind commented on GitHub (Jan 21, 2020):
@Jeoffreybauvin In the Case described by you I would not use
util.prompt_for_user_token, because it clearly states to be a utility to get you up and running quickly. When Implementing a custom RESt-API, I would instead operate the required Client-Classes directly.When removing all the input-checking and comments from
util.prompt_for_user_tokenthere is not a lot left:As an API-Implementor you have to provide the requisite options to
oauth2.SpotifyOAuthand have it request anauth_urlfor you. Depending on the Implementation of your REST-API I would return this URL to my client in order for it to open it in a popup or otherwise have my user access it.After the OAuth2 dance, the user is redirected to the
redirect_uriyou provided, which should be some url in your application (it might also be a local server if your writing a native app). The supplied code is then transferred to your REST-API in a second call, which can use it to requesttoken_infoon you users behalf.@stephanebruckert commented on GitHub (Feb 27, 2020):
For now this provides good inspiration to solve the issue https://github.com/plamere/spotipy/pull/435#issuecomment-583890341
@stephanebruckert commented on GitHub (May 30, 2020):
Just added an example here https://github.com/plamere/spotipy/blob/master/examples/app.py
@andrewhansen89 commented on GitHub (Jun 16, 2020):
Doesn't this example need a cache_path or username?