# Keychain Plugin

**URL:** <https://forum.ionicframework.com/t/keychain-plugin/28272>\
**Category:** cordova\
**Created:** [July 14, 2015, 3:38am UTC](https://forum.ionicframework.com/t/keychain-plugin/28272 "2015-07-14T03:38:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hpwah](https://avatars.discourse-cdn.com/v4/letter/h/22d042/32.png) [@hpwah](https://forum.ionicframework.com/u/hpwah)\
**Post date:** [July 14, 2015, 3:38am UTC](https://forum.ionicframework.com/t/keychain-plugin/28272/1 "2015-07-14T03:38:09Z")

</div>

I requires to add “Keychain” plugin in the project.

After I add the plugin with the following command, and add the sample code, there is an error that says Cannot find variable “Keychain”

Command: cordova plugin add [https://github.com/shazron/KeychainPlugin.git](https://github.com/shazron/KeychainPlugin.git)  
Sample code:  
$cordovaKeychain.setForKey(key, serviceName, value).then(function(value) {  
console.log(value);  
}, function (err) {  
console.error(err);  
});

Error:

0 702526 error Error: Can’t find variable: Keychain  
setForKey@[http://10.70.153.147:8100/lib/ngCordova/dist/ng-cordova.js:4133:30](http://10.70.153.147:8100/lib/ngCordova/dist/ng-cordova.js:4133:30)  
setKeychainValue@[http://10.70.153.147:8100/js/keychain.js:7:30](http://10.70.153.147:8100/js/keychain.js:7:30)

Anyone has similar experience can advise?

Appreciate a lot!

---

<div class="post-metadata">

**Author:** ![hpwah](https://avatars.discourse-cdn.com/v4/letter/h/22d042/32.png) [@hpwah](https://forum.ionicframework.com/u/hpwah)\
**Post date:** [July 17, 2015, 7:29am UTC](https://forum.ionicframework.com/t/keychain-plugin/28272/2 "2015-07-17T07:29:55Z")

</div>

Anyone has idea about this?

---

<div class="post-metadata">

**Author:** ![nitishrajput01](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/nitishrajput01/32/123978_2.png) [@nitishrajput01](https://forum.ionicframework.com/u/nitishrajput01)\
**Post date:** [July 17, 2015, 7:53am UTC](https://forum.ionicframework.com/t/keychain-plugin/28272/3 "2015-07-17T07:53:52Z")

</div>

// Get a reference to the plugin first  
var kc = new Keychain();

kc.setForKey(successCallback, failureCallback, ‘key’, ‘servicename’, ‘value’);

---

<div class="post-metadata">

**Author:** ![hpwah](https://avatars.discourse-cdn.com/v4/letter/h/22d042/32.png) [@hpwah](https://forum.ionicframework.com/u/hpwah)\
**Post date:** [July 19, 2015, 1:15am UTC](https://forum.ionicframework.com/t/keychain-plugin/28272/4 "2015-07-19T01:15:30Z")

</div>

Thank you sir.

I already add the cordova plugin [https://github.com/shazron/KeychainPlugin.git](https://github.com/shazron/KeychainPlugin.git)  
And the error happens in ng-cordova.js

Do you suggest me to use the plugin directly instead of using ng-cordova as a wrapper?

---

<div class="post-metadata">

**Author:** ![hpwah](https://avatars.discourse-cdn.com/v4/letter/h/22d042/32.png) [@hpwah](https://forum.ionicframework.com/u/hpwah)\
**Post date:** [July 23, 2015, 1:01am UTC](https://forum.ionicframework.com/t/keychain-plugin/28272/5 "2015-07-23T01:01:13Z")

</div>

Any developer from ionic can help to take a look? Appreciate a lot!!
