def init_config(): try: _create_directory_tree(FILE_DEFAULTS.config_file) config = configparser.ConfigParser(interpolation=None) config['PLAID'] = OrderedDict() plaid = config['PLAID'] client_id = prompt('Enter your Plaid client_id: ', validator=NullValidator()) plaid['client_id'] = client_id secret = prompt('Enter your Plaid secret: ', validator=NullValidator()) plaid['secret'] = secret except Exception as e: return False else: with open(FILE_DEFAULTS.config_file, mode='w') as f: config.write(f) return True
def create_account(account): try: _create_directory_tree(FILE_DEFAULTS.config_file) config = configparser.ConfigParser(interpolation=None) config[account] = OrderedDict() plaid = config[account] client_id, secret = get_plaid_config() # client_id = prompt('Enter your Plaid client_id: ', validator=NullValidator()) # plaid['client_id'] = client_id # secret = prompt('Enter your Plaid secret: ', validator=NullValidator()) # plaid['secret'] = secret configs = { 'user': { 'client_user_id': '123-test-user-id', }, 'products': ['transactions'], 'client_name': "Plaid Test App", 'country_codes': ['US'], 'language': 'en', } # create link token client = Client(client_id, secret, "development", suppress_warnings=True) response = client.LinkToken.create(configs) link_token = response['link_token'] generate_auth_page(link_token) print("\n\nPlease open " + FILE_DEFAULTS.auth_file + " to authenticate your account with Plaid") public_token = prompt('Enter your public_token from the auth page: ', validator=NullValidator()) # plaid['public_token'] = public_token response = client.Item.public_token.exchange(public_token) access_token = response['access_token'] plaid['access_token'] = access_token item_id = response['item_id'] plaid['item_id'] = item_id response = client.Accounts.get(access_token) accounts = response['accounts'] print("\n\nAccounts:\n") for item in accounts: print(item['name'] + ":") print(item['account_id']) account_id = prompt('\nEnter account_id of desired account: ', validator=NullValidator()) plaid['account'] = account_id except plaid_errors.ItemError as ex: print(" %s" % ex, file=sys.stderr ) sys.exit(1) else: with open(FILE_DEFAULTS.config_file, mode='a') as f: config.write(f) return True
def _present_question(self, question): clear_screen() print(question[0]) answer = prompt("Answer: ", validator=NullValidator( message="You must enter your answer", allow_quit=True)) if answer.lower() == "q": return False #we have abandoned ship self.connect_response = self.client.connect_step( self.account_type, answer) return True
def _get_needed_creds(self): credentials = self.active_institution["credentials"] clear_screen() print("Enter the required credentials for {}\n".format( self.active_institution["name"])) user_prompt = "Username ({}): ".format(credentials["username"]) pass_prompt = "Password ({}): ".format(credentials["password"]) pin = None username = prompt( user_prompt, validator=NullValidator(message="Please enter your username")) password = prompt( pass_prompt, is_password=True, validator=NullValidator(message="You must enter your password")) if "pin" in credentials: pin = prompt( "PIN: ", validator=NumLengthValidator( message="Pin must be at least {} characters long")) if not bool(pin) or pin.lower() == "q": pin = None #make sure we have something return username, password, pin
def _get_needed_creds(self): credentials = self.active_institution['credentials'] clear_screen() print('Enter the required credentials for {}\n'.format( self.active_institution['name'])) user_prompt = 'Username ({}): '.format(credentials['username']) pass_prompt = 'Password ({}): '.format(credentials['password']) pin = None username = prompt( user_prompt, validator=NullValidator(message='Please enter your username')) password = prompt( pass_prompt, is_password=True, validator=NullValidator(message='You must enter your password')) if 'pin' in credentials: pin = prompt( 'PIN: ', validator=NumLengthValidator( message='Pin must be at least {} characters long')) if not bool(pin) or pin.lower() == 'q': pin = None # Make sure we have something return username, password, pin