【问题标题】:"SpotifyOauthError: error: invalid_request, error_description: code must be supplied" when I input URL“SpotifyOauthError:错误:invalid_request,error_description:必须提供代码”当我输入 URL
【发布时间】:2021-05-27 13:55:51
【问题描述】:

下面是我的代码。我正在尝试获取令牌,以便进行身份验证。遇到问题,因为我没有被重定向到另一个 URL。我已经将 URI 输入到我的 Spotify 开发者应用程序中。不知道出了什么问题,或者我输入的 URL 是否不正确。输入为:https://www.google.com/。另外,目前正在使用 google collab,如果这有影响的话。

#client id and secret for my application
client_id = 'id' # hidden for now
client_secret= 'secret' # hidden for now

scope = 'user-library-read'

if len(sys.argv) > 1:
    username = sys.argv[1]
else:
    print("Usage: %s username" % (sys.argv[0],))
    sys.exit()

auth_manager = SpotifyClientCredentials(client_id=client_id, client_secret=client_secret)
sp = spotipy.Spotify(auth_manager=auth_manager)

token = util.prompt_for_user_token(username, scope, client_id= client_id, client_secret=client_secret, redirect_uri='https://www.google.com/')

【问题讨论】:

    标签: python authentication oauth-2.0 spotify


    【解决方案1】:

    我遇到了同样的问题,但在尝试访问我的图书馆时。

    我最终非常彻底地阅读了文档并找到了以下段落:

    redirect_uri 参数或 SPOTIPY_REDIRECT_URI 环境变量 必须与添加到您的应用程序中的重定向 URI 相匹配 仪表板。 重定向 URI 可以是任何有效的 URI(它不需要 可访问),例如http://example.com、http://localhost 或 http://127.0.0.1:9090.

    我的问题是我没有在开发者仪表板上将重定向 URI 添加到我的应用程序中。确保这些对于您的应用程序也是相同的,希望它能解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-01
      • 2019-01-11
      • 2020-10-27
      • 2022-08-19
      • 2021-07-12
      • 1970-01-01
      相关资源
      最近更新 更多