Saving to keychain not working

RyanEmptageRyanEmptage GBMember ✭✭

I'm trying to save our API token to Keychain using the following code:

var userId = "foo";
var token = "bar";
var updateSecRec = new SecRecord(SecKind.GenericPassword)
{
    Label = "MyApp",
    Description = "MyApp",
    Account = "",
    Service = "",
    Comment = "",
    ValueData = NSData.FromString(token),
    Generic = NSData.FromString(userId)
};

var saveResult = SecKeyChain.Add(updateSecRec);

No keychain entry has been added and when I inspect the value of saveResult in the debugger it shows -34018 instead of a SecStatusCode enum value.

Any ideas what could be wrong?

Tagged:

Best Answer

Answers

Sign In or Register to comment.