obscure-com / ti_keychain

iOS keychain wrapper for Appcelerator Titanium
78 stars 30 forks source link

Module working on simulator, but failing to retrieve data on iPhone devices #7

Open hugoeanogueira opened 10 years ago

hugoeanogueira commented 10 years ago

Hi. Used to have problems loading this modules in mobile devices (iPhone and iPad), but that is gone after the last issue fix/update. But the module seems to fail retrieving data when testing on devices (works fine in Simulator).

These were the methods I've used.

var Keychain  = require('com.obscure.keychain'),
    keychainItem = Keychain.createKeychainItem('server_account', 'passphrase'),
    getCredentials = function () {
        return {
            username: keychainItem.account,
            password: keychainItem.valueData
        };
    },
    saveCredentials = function () {
        var username = $.username.getValue().trim(),
            password = $.password.getValue().trim();

        keychainItem.account   = username;
        keychainItem.valueData = password;
        return this;
    };

I've also made a demo repository if you want to test by yourself. hugoeanogueira/testing_ti_keychain

Thanks!

romley commented 10 years ago

Any luck resolving this?

dottodot commented 10 years ago

I'm seeing the same issue when creating a keychainitem like

keychainItem = Keychain.createKeychainItem('server_account', 'passphrase'),

however using the method in the example seems to work ok, which is like

var userKeychainItem = keychain.createKeychainItem('username');
var passKeychainItem = keychain.createKeychainItem('password');
dottodot commented 10 years ago

This is the error I'm getting

[ERROR] :  creating keychain item: -25243
[ERROR] :      acct = "user2@example.com";
[ERROR] :      agrp = passphrase;
[ERROR] :      desc = "";
[ERROR] :      gena = "server_account";
[ERROR] :      icmt = "";
[ERROR] :      labl = "";
[ERROR] :      svce = "com.obscure.keychain";
[ERROR] :      "v_Data" = "";
[ERROR] :  }
[ERROR] :  creating keychain item: -25243
[ERROR] :      acct = "user2@example.com";
[ERROR] :      agrp = passphrase;
[ERROR] :      desc = "";
[ERROR] :      gena = "server_account";
[ERROR] :      icmt = "";
[ERROR] :      labl = "";
[ERROR] :      svce = "com.obscure.keychain";
[ERROR] :      "v_Data" = password;
[ERROR] :  }
ntchern commented 9 years ago

From source code and iOS documentation for this module looks like second argument in createKeychainItem is not ignored, but used as an access group. On the device this value should match your app's keychain-access-groups entitlements, and ignored on simulator. Try not to use second argument, or use it for Android only.

bd0 commented 8 years ago

Thank you @ntchern, that was exactly the problem!

hansemannn commented 7 years ago

For all others: Use osstatus.com to lookup error-codes. The keychain ones are pretty detailed and helpful. E.g. https://www.osstatus.com/search/results?platform=all&framework=all&search=-25243

@pegli I guess you can close this one.