Skip to content
Browse files

Add FAQ

  • Loading branch information...
1 parent f31d7f6 commit b8cc9fc068dcaade2f342817cd1752ee99694ea5 @iKenndac iKenndac committed
Showing with 42 additions and 0 deletions.
  1. +40 −0 FAQ.markdown
  2. +2 −0 README.markdown
View
40 FAQ.markdown
@@ -0,0 +1,40 @@
+# CocoaLibSpotify FAQ #
+
+## Logging in and Storing Credentials ##
+
+### How do I store credentials? ###
+
+If you want to save a user's login details for next time, do not store their password directly. Instead, implement the `SPSessionDelegate` method:
+
+For example:
+
+```
+
+-(void)session:(SPSession *)aSession didGenerateLoginCredentials:(NSString *)credential forUserName:(NSString *)userName {
+
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ NSMutableDictionary *storedCredentials = [[defaults valueForKey:@"SpotifyUsers"] mutableCopy];
+
+ if (storedCredentials == nil)
+ storedCredentials = [NSMutableDictionary dictionary];
+
+ [storedCredentials setValue:credential forKey:userName];
+ [defaults setValue:storedCredentials forKey:@"SpotifyUsers"];
+}
+
+```
+
+### session:didGenerateLoginCredentials:forUserName: is being called multiple times. Is this normal? ###
+
+Yes, the credentials token can and will be refreshed multiple times during your application's lifespan. Simply replace your last token with the newest one as the code snippet above does and you'll be fine.
+
+### Should I encrypt login tokens given to me by session:didGenerateLoginCredentials:forUserName:? ###
+
+The token is given to you is fine to be stored without encryption, so there's no need to go to special length to encrypt anything. It's important that you never directly save the user's password, though.
+
+### How long does the login token for a user last? What happens if I try to login with an invalid token that was previously valid? ###
+
+Login tokens last a very long time (measured in months/years), but they can be invalidated by a number of events, including the user changing their password. There's no way to tell before attempting login if the token is invalid.
+
+If you try to login with an invalid token, you'll get a login failure as normal. If the failure isn't due to some other problem (internet connection is offline, etc), simply discard your stored token and ask the user for their password again.
+
View
2 README.markdown
@@ -115,6 +115,8 @@ Once everything is set up, simply import the following header to get started wit
The headers of CocoaLibSpotify are well documented, and we've provided an Xcode DocSet to provide documentation right in Xcode. With these and the sample projects, you should have everything you need to dive right in!
+Additionally, there's an FAQ [right here in the repo](https://github.com/spotify/cocoalibspotify/blob/master/FAQ.markdown) that covers common usage questions.
+
## Unit Tests ##
CocoaLibSpotify now ships with a number of unit tests, which run inside a standalone application built by the project. If you find a bug in CocoaLibSpotify, please fork the project, add or modify a unit test so it fails (demonstrating the bug), then issue a pull request. We can then fix the underlying bug and keep your test so it stays that way.

0 comments on commit b8cc9fc

Please sign in to comment.
Something went wrong with that request. Please try again.