Hello! I’ve had to modify the 2SA authentication example in the readme because I’m creating an Alfred 3 workflow, so the first script looks like this:
‘’'
import sys, os, time
from workflow import Workflow3, ICON_WARNING, Variables
log = None
device = sys.argv[0]
def main(wf):
from pyicloud import PyiCloudService
login_info = None
for line in open("apidata.txt", "r").readlines():
login_info = line.split()
api = PyiCloudService(login_info[0], login_info[1])
api.send_verification_code(device)
if name == "main":
wf = Workflow3()
log = wf.logger
sys.exit(wf.run(main))
‘''
So that first script seems to work fine and send the verification code to whichever device the user has selected.
The problem is, in the second script, once the user has input their verification code, api.validate_verification_code(device, code) sends ANOTHER iCloud popup!
‘’'
import sys, os
from workflow import Workflow3, ICON_WEB, ICON_WARNING
auth_code = sys.argv[0]
def main(wf):
from pyicloud import PyiCloudService
login_info = None
for line in open("apidata.txt", "r").readlines():
login_info = line.split()
api = PyiCloudService(login_info[0], login_info[1])
if not api.validate_verification_code(auth_code):
wf.add_item(title="Failed to verify!",
subtitle='Please try again', valid="No", icon=ICON_WARNING)
wf.send_feedback()
else:
wf.add_item(title="Verified!",
subtitle='Use keyword "overhere" to find your lost device', valid="No")
wf.send_feedback()
if name == 'main':
wf = Workflow3()
log = wf.logger
wf.run(main)
‘’'
Alfred-workflow uses python 2.7, so I’m not sure if that’s the issue, or is it something to do with calling pyicloud from a different python program? I’m new to Python so sorry if this is a stupid question!