Is there a way to get the userId using the Spotify iOS SDK rather than using the web api?
Asked
Active
Viewed 619 times
2 Answers
1
Not sure if you're still looking, but SPTSession has a property:
/** @brief The canonical username of the authenticated user. */
@property (nonatomic, copy, readonly) NSString *canonicalUsername;
Which seems to be the id needed to make requests.

Samantha
- 2,269
- 2
- 13
- 25
0
Yes.
Here's an example of how to do it in Swift 3:
SPTUser.requestCurrentUser(withAccessToken:(SPTAuth.defaultInstance().session.accessToken)!) { (error, data) in
guard let user = data as? SPTUser else { print("Couldn't cast as SPTUser"); return }
let userId = user.canonicalUsername
})

Patrick Blaine
- 46
- 4