2017-02-02 60 views

回答

1

您需要为您的应用程序创建一个URL方案。喜欢的东西:

appName://SpotifyAuthentication

然后,当你注册Spotify的dev的帐户,您需要输入作为重定向的URI。当您在设备上发出请求时(GET https://accounts.spotify.com/authorize?client_id=.....&response_type=code& redirect_uri=appName%3A%2F%2FSpotifyAuthentication&.....),它将自动调用此URI并将在AppDelegate中调用:application:openURL:options:

URL查询字符串将包含您的身份验证令牌。 IE:appName://SpotifyAuthentication?authToken=someToken

+0

'authToken'和WebAPI'refresh_token'是否一样? – user25093

+1

@ user25093;这是不一样的。您将不得不向'POST https:// accounts.spotify.com/api/token'发出请求,以将'AuthToken'交换为'RefreshToken'。同样的逻辑适用。 – Brandon

+0

对不起,我很困惑,但我想澄清一些事情。 [是的](https://spotify.github.io/ios-sdk/Classes/SPTAuth.html),'SPTAuth',我会收到什么?每[步骤四](https://developer.spotify.com/web-api/authorization-guide/)我需要'grant_type','code'和'redirect_uri'。用'AuthToken'发布'https:// accounts.spotify.com/api/token'是否会返回'refresh_token'?我如何访问'AuthToken'? – user25093