Flutter spotify sdk - 刷新访问令牌
Flutter spotify sdk - refresh access token
我正在使用以下软件包:https://pub.dev/packages/spotify_sdk
这个包提供了方法getAuthenticationToken
,其中returns spotify 的访问令牌与我的服务器一起使用来检索一些与用户相关的 spotify 数据:
authenticationToken = await SpotifySdk.getAuthenticationToken(
clientId: dotenv.get('SPOTIFY_CLIENT_ID'),
redirectUrl: dotenv.get('SPOTIFY_AUTH_REDIRECT_URL'),
scope: 'user-read-email, user-top-read',
);
但是,此令牌将在 1 小时后过期。有没有什么办法,没有前端代码(只有服务器端)来刷新这个令牌?我有哪些选择?
tl;博士
没有直接的方法可以通过包获取刷新令牌。但是还有其他方法可以绕过这个限制。见旁路
功能可用性
通常 Spotify 认证 api 会包含一个刷新令牌,但 android sdk 中不存在此功能(cf: flutter package: #75 Android sdk: #12 #220 #225) although it is supported by the ios as well as the web sdk.
如果仅从 ios 或 Web 使用该应用程序,flutter 包的维护者 would most likely accept a pr that exposes the refresh methods of the supported platforms even though it would bring little value。
贡献功能
如果你熟悉android开发,并且该功能对你来说很重要,你可以尝试将此功能集成到android sdk中,然后暴露在flutter sdk中。
这里已经在 fork 中完成了:
制造商已经开了一个 pull request 但它还没有任何回应(2018 年底开放)。
绕过
一种绕过设备(或服务器)用户 would be to store the username and password 的方法,尽管从安全角度来看这很糟糕。
另一个灵感可能来自 this comment 来自 android-sdk 用户,他通过他的服务器路由身份验证。
我正在使用以下软件包:https://pub.dev/packages/spotify_sdk
这个包提供了方法getAuthenticationToken
,其中returns spotify 的访问令牌与我的服务器一起使用来检索一些与用户相关的 spotify 数据:
authenticationToken = await SpotifySdk.getAuthenticationToken(
clientId: dotenv.get('SPOTIFY_CLIENT_ID'),
redirectUrl: dotenv.get('SPOTIFY_AUTH_REDIRECT_URL'),
scope: 'user-read-email, user-top-read',
);
但是,此令牌将在 1 小时后过期。有没有什么办法,没有前端代码(只有服务器端)来刷新这个令牌?我有哪些选择?
tl;博士
没有直接的方法可以通过包获取刷新令牌。但是还有其他方法可以绕过这个限制。见旁路
功能可用性
通常 Spotify 认证 api 会包含一个刷新令牌,但 android sdk 中不存在此功能(cf: flutter package: #75 Android sdk: #12 #220 #225) although it is supported by the ios as well as the web sdk.
如果仅从 ios 或 Web 使用该应用程序,flutter 包的维护者 would most likely accept a pr that exposes the refresh methods of the supported platforms even though it would bring little value。
贡献功能
如果你熟悉android开发,并且该功能对你来说很重要,你可以尝试将此功能集成到android sdk中,然后暴露在flutter sdk中。
这里已经在 fork 中完成了:
制造商已经开了一个 pull request 但它还没有任何回应(2018 年底开放)。
绕过
一种绕过设备(或服务器)用户 would be to store the username and password 的方法,尽管从安全角度来看这很糟糕。
另一个灵感可能来自 this comment 来自 android-sdk 用户,他通过他的服务器路由身份验证。