Monday, March 25, 2013

Creating a new keychain on Mac

Recently, I wanted to make an app on my mac for logging onto my gmail account in Safari browser. Once I started looking into applescript I realized best way to use an login credentials is through mac native keychain access. For my GMail applescript I had to make a keychain and this is how I did it. First, open keychain access from applications. Goto File --> New Keychain or selecting New Keychain from the popup that comes up when you right click on the left pane as shown below:

 

I gave a name 'WebLogins' and created in a default location "/Users/manchu/Library/Keychains/"

 

Enter a password for the newly created keychain. This keeps all your username and password combinations we're going to keep in this keychain secure just in case some one got hold of your system.



Now click on WebLogins in the left pane and then click on "+" all the way below immediately next to the left pane. This would ask you to give a name to the item you're going to create. I gave it GMailPersonal as I'm going to use this item for logging onto my GMail web account. For account name I use my GMail username and for Password I use my GMail account password. Save it by clicking "Add".

 

Next step is to change the settings for this Keychain. Right click on "WebLogins" and select 'Change Settings for Keychain "WebLogins"...' as shown below:

 

Since I need my app to access these credentials randomly I uncheck the first item as I don't want to enter the keychain password every time it accesses the keychain. Since I use this to see my gmail it doesn't make sense to uncheck "Lock when sleeping" as I don't need to activate my app either remotely or make it run at certain time in a day (let's say cron job) in my absence.

 

In my applescript I use the tool security to access the username and password from the WebLogins keychain. You'd be asked to either always allow or deny or just one-time allow the security to access the username and password. I go for always allow as I don't want to enter keychain password through out the day.

 

Whenever you logout of or restart the system you will be asked to enter the keychain password as a security feature. As you see security tool is trying to use the password.

 

No comments:

PBS Script Generator: Interdependent dropdown/select menus in Javascript

PBS SCRIPT GENERATOR
SH/BASH TCSH/CSH
Begin End Abort

About Me

LA, CA, United States
Here I write about the battles that have been going on in my mind. It's pretty much a scribble.

Sreedhar Manchu

Sreedhar Manchu
Higher Education: Not a simple life anymore