Search code examples
ioshttpsdktokenspotify

Can I use the token from iOS SDK in Web API requests?


I wanted to use Spotify SDK in an iOS app for login and then use the token from SDK to perform Web API requests. Is that the correct token for my use case?

Spotify iOS SDK: iOS SDK | Spotify for Developers

Spotify Web API: Web API | Spotify for Developers


Solution

  • It is the correct token to use but be sure to request all the scopes you will need for the Web API. Here is the iOS SDK documentation for using scopes with iOS: https://spotify.github.io/ios-sdk/html/Constants/SPTScope.html

    An example using SPTScope:

    let requestedScopes: SPTScope = [
        .appRemoteControl, 
        .userReadEmail, 
        .userReadPrivate, 
        .streaming
    ] 
    sessionManager.initiateSession(with: requestedScopes, options: .default)