Locksmith icon indicating copy to clipboard operation
Locksmith copied to clipboard

Setting LocksmithAccessibleOption.Always for reading data from background

Open mmalek-sa opened this issue 9 years ago • 4 comments

I need to load data from background:

let dictionary = Locksmith.loadDataForUserAccount("myUserAccount")

but I get the InteractionNotAllowed error. I figured out that I need to some how set the LocksmithAccessibleOption to Always. but I don't use protocols I just use simple:

try Locksmith.saveData(["some key": "some value"], forUserAccount: "myUserAccount")

and I don't find any way to set LocksmithAccessibleOption here.

And one side question (Sorry I don't know if this is the place to ask this question):

In example TwitterAccount this code confuses me:

let account = TwitterAccount(username: "_matthewpalmer", password: "my_password")

// ReadableSecureStorable lets us read the account from the keychain
let result = account.readFromSecureStore()

In order to read the twitter account data for user we need to create an instance of TwitterAccount with username and password, but I thought the whole point is we don't know username and password of the twitter account and want to retrieve that data from keychain of the device. If we know the username and password of the user, what are we reading from secure store?

mmalek-sa avatar Nov 30 '15 12:11 mmalek-sa

Hi

Thanks for using Locksmith!

Re the first point, there's no way to pass in the accessibility options via those class methods. Your best option is to wrap a class method around an internal protocol-conforming type. This is how the library-provided class methods work, so you will probably be able to use those as examples.

Re the second point. I've been hearing that a little lately, so I think I'm going to rewrite the README to be more clear when I get time.

Thanks very much, Matt

On 30 Nov 2015, at 11:25 PM, Mani [email protected] wrote:

I need to load data from background:

let dictionary = Locksmith.loadDataForUserAccount("myUserAccount") but I get the InteractionNotAllowed error. I figured out that I need to some how set the LocksmithAccessibleOption to Always. but I don't use protocols I just use simple:

try Locksmith.saveData(["some key": "some value"], forUserAccount: "myUserAccount") and I don't find any way to set LocksmithAccessibleOption here.

And one side question (Sorry I don't know if this is the place to ask this question):

In example TwitterAccount this code confuses me:

let account = TwitterAccount(username: "_matthewpalmer", password: "my_password")

// ReadableSecureStorable lets us read the account from the keychain let result = account.readFromSecureStore() In order to read the twitter account data for user we need to create an instance of TwitterAccount with username and password, but I thought the whole point is we don't know username and password of the twitter account and want to retrieve that data from keychain of the device. If we know the username and password of the user, what we are reading from secure store?

— Reply to this email directly or view it on GitHub.

matthewpalmer avatar Dec 01 '15 06:12 matthewpalmer

Thank you for the great work. Since I had a deadline to catch today, I used this Keychain wrapper and changed the accessibility option in that code.

mmalek-sa avatar Dec 01 '15 09:12 mmalek-sa

@mani47 Had the same problem. Ended up getting rid of this library and using KeychainAccess which is much less dogmatic. All these protocols and lack of any decent documentation were deal breakers.

danielrhodes avatar Jul 24 '16 12:07 danielrhodes

"Your best option is to wrap a class method around an internal protocol-conforming type". Could you elaborate on this, Matt? It is not at all clear from looking at the code what you are talking about doing.

gumbright-sf avatar Nov 07 '16 16:11 gumbright-sf