def get(self, user): userData = User.get(User.username == user) userData = model_to_dict(userData) access_token = userData['accessToken'] #print(access_token) client = Client(client_id=id, secret=secret, access_token=access_token) balance = client.balance().json() return balance
def test_unauthorizedError_bad_password(): client = Client('test_id', 'test_secretz') with pytest.raises(UnauthorizedError): client.balance()
def test_unauthorizedError_bad_username(): client = Client('test_idz', 'test_secret') with pytest.raises(UnauthorizedError): client.balance()
def test_UnauthorizedError_bad_token(): client = Client('test_id', 'test_secret', 'test_zoba') with pytest.raises(UnauthorizedError): client.balance()
def test_balance(): client = Client('test_id', 'test_secret', access_token='test_bofa') response = client.balance() assert response.status_code == 200
def test_balance_requires_access_token(): client = Client('myclientid', 'mysecret') with pytest.raises(Exception): client.balance()
def test_balance(): with patch('requests.get') as mock_requests_get: client = Client('myclientid', 'mysecret', 'token') ret = client.balance() assert mock_requests_get.called assert ret is not None
return client.connect_step(account_type, answer) try: response = client.connect(account_type, { 'username': username, 'password': password }) except plaid_errors.PlaidError, e: pass else: if response.status_code == 200: # User connected data = json.loads(response.content) elif response.status_code == 201: # MFA required try: mfa_response = answer_mfa(json.loads(response.content)) except plaid_errors.PlaidError, e: pass else: # check for 200 vs 201 responses # 201 indicates that additional MFA steps required phone_code = raw_input('Enter your ID code from your phone: ') connected = client.connect_step(account_type, phone_code) balances = client.balance().json() response = client.connect_get() transactions = json.loads(response.content)
import os, json from plaid import Client from plaid import errors as plaid_errors plaid_client_id = os.getenv('plaid_client_id', '') plaid_secret = os.getenv('plaid_secret', '') plaid_access_token = os.getenv('plaid_access_token', '') Client.config({ 'url': 'https://api.plaid.com', 'suppress_http_errors': True, }) client = Client(client_id=plaid_client_id, secret=plaid_secret, access_token=plaid_access_token) response = client.balance() balance = json.loads(response.content) response = client.connect_get() transactions = json.loads(response.content) print balance