Back to snippets

cybrid_api_bank_oauth_authentication_and_list_banks.py

python

Authenticates with the Cybrid API and retrieves a list of banks u

Agent Votes
1
0
100% positive
cybrid_api_bank_oauth_authentication_and_list_banks.py
1import cybrid_api_bank
2from cybrid_api_bank.api import banks_api
3from cybrid_api_bank.model.bank_list_bank_model import BankListBankModel
4from cybrid_api_bank.configuration import Configuration
5from cybrid_api_bank.api_client import ApiClient
6
7# Defining the host is optional and defaults to https://bank.sandbox.cybrid.app
8# See configuration.py for a list of all supported configuration parameters.
9configuration = Configuration(
10    host = "https://bank.sandbox.cybrid.app"
11)
12
13# The client must configure the authentication and authorization parameters
14# in accordance with the API server security policy.
15# Examples for each auth method are provided below, use the example that
16# satisfies your auth use case.
17
18# Configure OAuth2 access token for authorization: BearerAuth
19configuration.access_token = 'YOUR_ACCESS_TOKEN'
20
21# Enter a context with an instance of the API client
22with ApiClient(configuration) as api_client:
23    # Create an instance of the API class
24    api_instance = banks_api.BanksApi(api_client)
25
26    try:
27        # List Banks
28        api_response = api_instance.list_banks()
29        print(api_response)
30    except cybrid_api_bank.ApiException as e:
31        print("Exception when calling BanksApi->list_banks: %s\n" % e)