Keychain: Application still requesting access with entry created via "security add-generic-password"

In newer versions of OS X you now have to add a partition teamid

security set-generic-password-partition-list -S teamid:UBF8T346G9 -s "Exchange" -k YOUR_USER_PW

If you 'allow' Exchange or whichever app to use the password and then inspect it

security dump-keychain -a > blip.txt

You can see the teamid and then use that in the command above. For instance for Sequel Pro:

    class: "genp"
    attributes:
        0x00000007 <blob>="Sequel Pro : mydb (5180261558162063037)"
    ...
        entry 3:
            authorizations (1): partition_id
            don't-require-password
            description: teamid:Y48LQG59RS
            applications: <null>
    ...

Now when you script this trusted password you can use:

    security add-generic-password -a "me@localhost/mydb" -s "my db" -p thepasswordtomydb -T "/Applications/Sequel Pro.app" -U
    security set-generic-password-partition-list -S teamid:Y48LQG59RS -s "my db" -k your_user_pw