小编Shr*_*pre的帖子

Google Colab - Spotipy 没有将我重定向到指定的redirect_uri

我想使用 Spotipy python 包来试验 Spotify API。

\n

首先,在我的 Spotify Developer 应用程序中,\n我已将redirect_uri 设置为https://example.com/callback/

\n

这是我尝试在 Google Colab 笔记本上运行的代码

\n
import pandas as pd\nimport spotipy\nfrom spotipy.oauth2 import SpotifyClientCredentials\n\nspotify_details = {\n    \'client_id\' : \'<hidden>\',\n    \'client_secret\':\'<hidden>\',\n    \'redirect_uri\':\'https://example.com/callback/\'}\n\nscope = "user-library-read user-follow-read user-top-read playlist-read-private" \n\nsp = spotipy.Spotify(\n        auth_manager=spotipy.SpotifyOAuth(\n          client_id=spotify_details[\'client_id\'],\n          client_secret=spotify_details[\'client_secret\'],\n          redirect_uri=spotify_details[\'redirect_uri\'],    \n          scope=scope))\n\nresults = sp.current_user_saved_tracks()\nfor idx, item in enumerate(results[\'items\']):\n    track = item[\'track\']\n    print(idx, track[\'artists\'][0][\'name\'], " \xe2\x80\x93 ", track[\'name\'])\n
Run Code Online (Sandbox Code Playgroud)\n

这就是我所看到的输出:

\n

在此输入图像描述

\n

但我的浏览器没有将我重定向到任何 URL 来接收身份验证令牌

\n

我究竟做错了什么?

\n

python spotify jupyter-notebook spotipy google-colaboratory

2
推荐指数
1
解决办法
1921
查看次数