【发布时间】:2021-11-04 02:07:53
【问题描述】:
我制作的脚本在本地运行时运行良好,但无法在我的 Azure Functions 应用程序中进行身份验证。一开始我以为是因为它无法读取.cache文件。
查看日志后,这是因为它无法打开浏览器窗口来创建身份验证令牌。我对 Azure 功能还很陌生,所以我不确定如何启用打开浏览器(如果可能的话)。
我在 spotipy 中查看了 oauth2.py 文件,发现打开浏览器是可选的,但是控制台要求提供重定向的 URL。有没有办法让我获取重定向的 URL 并将其输入到控制台中?
这是我的代码:
def create_playlist(cred):
"""Creates the playlist for Discover weekly to be copied to"""
# Gain authorization to create playlist
logging.info('Authenticating spotify secrets to create new playlist...')
# spotipy.CacheFileHandler(cache_path='')
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=cred[0],
client_secret=cred[1],
redirect_uri=cred[2],
scope='playlist-modify-private',
open_browser=False,
))
# Get returned list from get_playlist_info function
logging.info('Determining playlist descriptors...')
info = get_playlist_info()
# New playlist for Discover Weekly
logging.info('Creating new playlist...')
new_playlist = sp.user_playlist_create(user=cred[4],
name=info[0],
public=False,
collaborative=False,
description=info[1])
logging.info('Returning new playlist.')
return new_playlist
【问题讨论】:
标签: python azure azure-functions spotipy