Spotify API 自动初始授权
Spotify API automated initial authorization
我正在制作个人智能镜子,我希望集成 spotify API 来显示我的 'currently playing' 曲目。但是,我注意到在授权过程中,您需要实际单击登录并授权该应用程序,以便获得继续获取数据所需的凭据。这可能是 automated/require 没有用户交互吗?
我指的是 api authorization guide 的第 1 步。
非常感谢。
如果您将其用于个人智能镜子,应该没有问题。您只需在浏览器中单击一个按钮一次即可授权,之后无需单击任何内容即可进行所有 API 调用。
具体来说,在您完成授权流程的第 3 步后,您将获得一个刷新令牌。授权令牌过期后,您可以使用刷新令牌自动刷新授权,无需单击任何内容。
来自他们的文档:
Accessing your data without showing a login form
I want to interact with the web API and show some data on my website. I see that the endpoints I need authorization, but I don’t need/want a login window to pop-up, because I want to grant my own app access to my own playlists once. Is there any way of doing this?
You basically need an access token and a refresh token issued for your
user account. For obtaining a pair of access token / refresh token you
need to follow the Authorization Code Flow (if you need a certain
scope to be approved) or Client Credentials (if you just need to sign
your request, like when fetching a certain playlist). Once you obtain
them, you can use your access token and refresh it when it expires
without having to show any login form.
如果它不适合你个人,你可以跳槽并编写伪装成网络浏览器的代码,也许使用 curl 或 selenium 之类的东西,但很可能这违反了他们的服务条款,如果你被抓到他们会禁止你的。
我正在制作个人智能镜子,我希望集成 spotify API 来显示我的 'currently playing' 曲目。但是,我注意到在授权过程中,您需要实际单击登录并授权该应用程序,以便获得继续获取数据所需的凭据。这可能是 automated/require 没有用户交互吗?
我指的是 api authorization guide 的第 1 步。
非常感谢。
如果您将其用于个人智能镜子,应该没有问题。您只需在浏览器中单击一个按钮一次即可授权,之后无需单击任何内容即可进行所有 API 调用。
具体来说,在您完成授权流程的第 3 步后,您将获得一个刷新令牌。授权令牌过期后,您可以使用刷新令牌自动刷新授权,无需单击任何内容。
来自他们的文档:
Accessing your data without showing a login form
I want to interact with the web API and show some data on my website. I see that the endpoints I need authorization, but I don’t need/want a login window to pop-up, because I want to grant my own app access to my own playlists once. Is there any way of doing this?
You basically need an access token and a refresh token issued for your user account. For obtaining a pair of access token / refresh token you need to follow the Authorization Code Flow (if you need a certain scope to be approved) or Client Credentials (if you just need to sign your request, like when fetching a certain playlist). Once you obtain them, you can use your access token and refresh it when it expires without having to show any login form.
如果它不适合你个人,你可以跳槽并编写伪装成网络浏览器的代码,也许使用 curl 或 selenium 之类的东西,但很可能这违反了他们的服务条款,如果你被抓到他们会禁止你的。