大佬教程收集整理的这篇文章主要介绍了Google Colab - Spotipy 没有将我重定向到指定的 redirect_uri,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想使用 Spotipy python 包试验 Spotify API。
首先,在我的 Spotify 开发者应用中, 我已将 redirect_uri 设置为 https://example.com/callBACk/
这是我试图在 Google Colab 笔记本上运行的代码
import pandas as pd
import spotipy
from spotipy.oauth2 import SpotifyClIEntCredentials
spotify_details = {
'clIEnt_ID' : '<hIDden>','clIEnt_secret':'<hIDden>','redirect_uri':'https://example.com/callBACk/'}
scope = "user-library-read user-follow-read user-top-read playList-read-private"
sp = spotipy.Spotify(
auth_manager=spotipy.SpotifyOAuth(
clIEnt_ID=spotify_details['clIEnt_ID'],clIEnt_secret=spotify_details['clIEnt_secret'],redirect_uri=spotify_details['redirect_uri'],scope=scopE))
results = sp.current_user_saved_tracks()
for IDx,item in enumerate(results['items']):
track = item['track']
print(IDx,track['artists'][0]['name']," – ",track['name'])
这是我看到的输出:
但我的浏览器没有将我重定向到任何 URL 以接收身份验证令牌
我做错了什么?
Colab 是一个无浏览器的环境,因此建议 in the FAQ 您应该添加参数
open_browser=false
当您实例化 spotipy.SpotifyOAuth 对象时:
sp = spotipy.Spotify(
auth_manager=spotipy.SpotifyOAuth(
client_id=spotify_details['client_id'],client_secret=spotify_details['client_secret'],redirect_uri=spotify_details['redirect_uri'],scope=scope,open_browser=falsE))
这样notebook就会打印出你可以手动打开的URL:
以上是大佬教程为你收集整理的Google Colab - Spotipy 没有将我重定向到指定的 redirect_uri全部内容,希望文章能够帮你解决Google Colab - Spotipy 没有将我重定向到指定的 redirect_uri所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。