Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to choose account and service values for SSKeychain

I'm thinking of using SSKeychain for storing a password in an iOS app, but I'm not sure if I need some specific value for the account and service, or if it will be OK with just arbitrary ones. Is there a common practice?

like image 868
Jakob W Avatar asked Oct 05 '11 15:10

Jakob W


1 Answers

The Service should be a unique string for your App, possibly use the iOS Bundle Identifier as the Service or the name/URL of your Application or Web App or whatever you are setting the Password for. This should ideally be constant throughout your Application but there is no specific preference. I personally prefer to set it to the Web Service URL but that is my preference.

The account bit is in essence similar to a Username field on any application. That's so you can store multiple passwords for the same service but for different accounts. If you are working on an application which doesn't have a username field then you could set it to 'user' or something arbitrary but remains constant throughout the application and in future versions.

So if I am storing the password for joebloggs with password 'test' for the acme.com service, here is how I'd store it:

NSString *password = [SSKeychain setPassword:@"test" forService:@"acme.com" account:@"joebloggs"];

SSKeychain is so easy and fantastic to use. Definitely a good choice!

like image 113
Suhail Patel Avatar answered Oct 29 '22 22:10

Suhail Patel