简体   繁体   English

Spotify iOS SDK刷新令牌

[英]Spotify iOS SDK Refresh Tokens

Evening all! 晚上都好!

Quick question for all of those who are familiar with the Spotify iOS SDK . 对于所有熟悉Spotify iOS SDK的人来说,这是一个快速问题。

(Please note: For those who don't, please don't provide any assistance because it is a procedural question rather than a programatic question). (请注意:对于那些不这样做的人,请不要提供任何帮助,因为这是程序性问题而不是程序性问题)。

So, I have successfully authenticated and received a session token (and accompanying Refresh_Token on the server). 因此,我已经成功通过身份验证并收到了会话令牌(以及服务器上随附的Refresh_Token)。 My understanding is that the Refresh_Token is not passed back to the iOS app and should be stored on the server to be used when the original session has expired and you need to renew without user interaction. 我的理解是,Refresh_Token不会传递回iOS应用,而应存储在服务器上,以在原始会话到期时使用,并且需要在无需用户交互的情况下进行续订。

My question is how are people storing the Refresh_Token? 我的问题是人们如何存储Refresh_Token? Surely you would need to store it alongside the user's Spotify username (which is never disclosed to the tokenswap server?!). 当然,您需要将其与用户的Spotify用户名(永远不会透露给tokenswap服务器?!)一起存储。 How would I go about getting the username? 我将如何获取用户名?

I've played around to see what gets passed to the Token Swap server, when you first request a session, it passes Code and returns Session , Bearer , Expires and Refresh Token . 我到处玩耍,看看传递给令牌交换服务器的内容是什么,当您第一次请求会话时,它将传递Code并返回SessionBearerExpiresRefresh Token When you ask for a renew, it passes the Spotify username only. 当您要求续约时,它仅传递Spotify用户名。 So I don't have anything which is kept the same across both requests to use as a unique identifier of which user is making the request. 因此,我没有任何在两个请求中都保持相同的东西来用作发出该请求的用户的唯一标识符。

Hopefully, that can be understood! 希望可以理解! Please don't hesitate to ask for clarification!! 请不要犹豫,要求澄清!

Thanks! 谢谢!

The Spotify iOS SDK ships with a token swap server that stores refresh tokens by username for you. Spotify iOS SDK附带有令牌交换服务器,该服务器按用户名存储刷新令牌。 Open it up and you'll have en example on how to do exactly what you want to do: 打开它,您将获得有关如何正确执行所需操作的示例:

https://github.com/spotify/ios-sdk/blob/master/Demo%20Projects/spotify_token_swap.rb https://github.com/spotify/ios-sdk/blob/master/Demo%20Projects/spotify_token_swap.rb

Basically, have your token swap server do a request to the /me endpoint to get the username. 基本上,让您的令牌交换服务器向/me端点发出请求以获取用户名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM