【发布时间】:2020-11-02 08:16:13
【问题描述】:
我正在使用 Spotify API 开发一个应用程序,但我对这一切有点陌生。我正在尝试使用代码交换证明密钥 (PKCE) (https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow-with-proof-key-for-code-exchange-pkce) 获取授权代码
我的问题是如何将用户重定向到query 他必须接受授权并让我的应用程序等到用户点击接受。当他这样做时,用户将被重定向,并且该新 URL(如文档所述)将包含我需要的授权代码,然后将其交换为授权令牌。
这是我目前获取授权码的功能:
def get_auth_code(self):
code_challenge = self.get_code_challenge_PKCE()
scopes_needed = "user-read-email%20user-read-private%20playlist-read-collaborative%20playlist-modify-public%20playlist-read-private%20playlist-modify-private%20user-library-modify%20user-library-read"
endpoint = "https://accounts.spotify.com/authorize"
query = f"{endpoint}?client_id={self.client_ID}&response_type=code&redirect_uri={self.redirect_uri}&scope={scopes_needed}&code_challenge_method=S256&code_challenge={code_challenge}"
webbrowser.open(query)
【问题讨论】:
标签: python authentication oauth-2.0 authorization spotify