SPLoginViewController to remember credentials

cocoalibspotify-2.0, spotify

Solution

You don't.

Instead, implement the `SPSessionDelegate` method `-session:didGenerateLoginCredentials:forUserName:` and store the credentials in `NSUserDefaults` or whatever (the given credentials are already encrypted and safe for storing in cleartext).

Next time your app launches, if you have available credentials skip `SPLoginViewController`entirely and login using `SPSession`'s `attemptLoginWithUserName:existingCredential:rememberCredentials:` method. If this generates a login error, the token has been invalidated and you need to ask the user to login again — invalidation can happen if the user changes their password since the token was generated.

Note that the `rememberCredentials:` parameters and the old `attemptLoginWithStoredCredentials:` way of doing things is now considered deprecated and will be going away soon.

Problem

In CocoaLibSpotify, how do I get SPLoginViewController to store credentials, so users later can login automatically via [[SPSession sharedSession] attemptLoginWithStoredCredentials:]?

Original source