def test_bank_branch_list(self): auth = OAuthHandler(oauth_client_id, oauth_client_secret, get_private_key(), redirect_uri) auth.get_access_token_via_client_credentials_flow(['public']) api = API(auth) r = api.bank_branch_list(bankId=205, cityId=34) self.assertTrue(r.success) try: r = api.bank_branch_list(bankId=205, cityId=34) except KTError as error: self.assertTrue('cityId' in error.reason)
def test_client_credentials_access_token(self): auth = OAuthHandler(oauth_client_id, oauth_client_secret, get_private_key(), redirect_uri) # test getting access token auth.get_access_token_via_client_credentials_flow(['public']) self.assert_(auth.access_token is not None) # use the access token to verify that it is valid api = API(auth) r = api.test_customer_list() self.assert_(r.success)
def test_authorization_code_access_token(self): auth = OAuthHandler(oauth_client_id, oauth_client_secret, get_private_key(), redirect_uri) scopes = ['accounts'] authorization_url = auth.get_authorization_url(scopes) print('Please authorize: ' + authorization_url) code = input('Enter the authorization code from the callback URL') auth.get_access_token_via_authorization_code_flow(code) self.assert_(auth.access_token is not None) # use the access token to verify that it is valid api = API(auth) r = api.account_list() self.assert_(r.success)
def test_test_customer_list(self): auth = OAuthHandler(oauth_client_id, oauth_client_secret, get_private_key(), redirect_uri) api = API(auth) r = api.test_customer_list() self.assertTrue(r.success) self.assertEqual(len(r.value), 5)
def test_collection_list(self): auth = OAuthHandler(oauth_client_id, oauth_client_secret, get_private_key(), redirect_uri) api = API(auth) data = { "accountNumber": 8002577, "accountSuffix": 1, "processId": 421553, "isPTTCollection": "false" } r = api.collection_list(data) self.assertTrue(r.success)
def test_generic_request(self): auth = OAuthHandler(oauth_client_id, oauth_client_secret, get_private_key(), redirect_uri) api = API(auth) endpoint_params = { 'path': '/v1/data/testcustomers', 'method': 'GET', 'scope': 'public', 'authorization_flow': 'client credentials' } r = api.generic_request(endpoint_params) self.assertTrue(r.success) self.assertEqual(len(r.value), 5)
from kuveytturk.api import API from kuveytturk.auth import OAuthHandler from kuveytturk.error import KTError CLIENT_ID = '' CLIENT_SECRET = '' REDIRECT_URI = '' PRIVATE_KEY = '' # Create an authentication handler with your credentials auth = OAuthHandler(CLIENT_ID, CLIENT_SECRET, PRIVATE_KEY, REDIRECT_URI) # Then create an API instance using this authentication handler api = API(auth) try: response = api.test_customer_list() except KTError as err: pass for customerId in response.value: print(customerId)
from kuveytturk.api import API from kuveytturk.auth import OAuthHandler from kuveytturk.error import KTError CLIENT_ID = '' CLIENT_SECRET = '' REDIRECT_URI = '' PRIVATE_KEY = '' # Create an authentication handler with your credentials auth = OAuthHandler(CLIENT_ID, CLIENT_SECRET, PRIVATE_KEY, REDIRECT_URI) # Then create an authorization url to get consent of the user. scopes = ['accounts'] authorization_url = auth.get_authorization_url(scopes) print('Please authorize: ' + authorization_url) code = input('Enter the authorization code from the callback URL') # Using the authroziation code, request an access token auth.get_access_token_via_authorization_code_flow(code) # Then create an API instance using this authentication handler api = API(auth) # Finally make the api request to retrieve the list of account information # of the authenticated customer. try: response = api.account_list() except KTError as err: pass
def create_auth(): auth = OAuthHandler(oauth_client_id, oauth_client_secret, get_private_key(), redirect_uri) return auth