-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetpwd.py
More file actions
24 lines (21 loc) · 748 Bytes
/
Copy pathgetpwd.py
File metadata and controls
24 lines (21 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
##Fetch password from keychain with touchid authentication
import keychain, sys
try:
from touchid import authenticate
except ImportError:
Exception("Couldn't load touchid module")
def get_apikey(service="", account=""):
assert service is not None and account is not None
d = {}
d.update(keychain.get_services())
if service in d:
assert d.get(service, "") == account
PWD = keychain.get_password(service, account)
touchid_status = 0
touchid_status = authenticate("Authenticate API lookup", allow_passcode=True, timeout=10)
if touchid_status:
return PWD
else:
sys.stderr.write("Bad fingerprint!")
else:
raise Exception("API key not found")