Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bandwidth/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class Configuration:
:param username: Username for HTTP basic authentication.
:param password: Password for HTTP basic authentication.
:param access_token: Access token.
:param access_token_url: URL to get access token for OAuth2 authentication.
:param client_id: Client ID for OAuth2 authentication.
:param client_secret: Client Secret for OAuth2 authentication.
:param server_index: Index to servers configuration.
Expand Down Expand Up @@ -201,6 +202,7 @@ def __init__(
username: Optional[str]=None,
password: Optional[str]=None,
access_token: Optional[str]=None,
access_token_url: Optional[str]=None,
client_id: Optional[str]=None,
client_secret: Optional[str]=None,
server_index: Optional[int]=None,
Expand Down Expand Up @@ -258,6 +260,9 @@ def __init__(
self.access_token = access_token
"""Access token
"""
self.access_token_url = 'https://api.bandwidth.com/api/v1/oauth2/token' if access_token_url is None else access_token_url
"""URL to get access token for OAuth2 authentication
"""
self.client_id = client_id
"""Client ID for OAuth2 authentication
"""
Expand Down Expand Up @@ -540,7 +545,7 @@ def get_access_token(self) -> str:
auth_header = f"Basic {_encoded_string}"
resp = urllib3.request(
'POST',
'https://api.bandwidth.com/api/v1/oauth2/token',
self.access_token_url,
headers={
'Authorization': auth_header,
'Content-Type': 'application/x-www-form-urlencoded',
Expand Down
7 changes: 6 additions & 1 deletion custom_templates/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class Configuration:
:param username: Username for HTTP basic authentication.
:param password: Password for HTTP basic authentication.
:param access_token: Access token.
:param access_token_url: URL to get access token for OAuth2 authentication.
:param client_id: Client ID for OAuth2 authentication.
:param client_secret: Client Secret for OAuth2 authentication.
{{#hasHttpSignatureMethods}}
Expand Down Expand Up @@ -288,6 +289,7 @@ conf = {{{packageName}}}.Configuration(
username: Optional[str]=None,
password: Optional[str]=None,
access_token: Optional[str]=None,
access_token_url: Optional[str]=None,
client_id: Optional[str]=None,
client_secret: Optional[str]=None,
{{#hasHttpSignatureMethods}}
Expand Down Expand Up @@ -348,6 +350,9 @@ conf = {{{packageName}}}.Configuration(
self.access_token = access_token
"""Access token
"""
self.access_token_url = {{#authMethods}}{{#isOAuth}}'{{tokenUrl}}'{{/isOAuth}}{{/authMethods}} if access_token_url is None else access_token_url
"""URL to get access token for OAuth2 authentication
"""
self.client_id = client_id
"""Client ID for OAuth2 authentication
"""
Expand Down Expand Up @@ -651,7 +656,7 @@ conf = {{{packageName}}}.Configuration(
auth_header = f"Basic {_encoded_string}"
resp = urllib3.request(
'POST',
{{#authMethods}}{{#isOAuth}}'{{tokenUrl}}',{{/isOAuth}}{{/authMethods}}
self.access_token_url,
headers={
'Authorization': auth_header,
'Content-Type': 'application/x-www-form-urlencoded',
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_calls_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class TestCallsApi(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
configuration = Configuration(
client_id=BW_CLIENT_ID,
client_secret=BW_CLIENT_SECRET,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_conferences_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ class TestConferencesApi(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
configuration = Configuration(
client_id=BW_CLIENT_ID,
client_secret=BW_CLIENT_SECRET,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_endpoints_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class TestEndpointsApi(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
configuration = Configuration(
client_id=BW_CLIENT_ID,
client_secret=BW_CLIENT_SECRET,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_media_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class TestMediaApi(unittest.TestCase):

def setUp(self) -> None:
configuration = Configuration(
username=BW_USERNAME,
password=BW_PASSWORD,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_messages_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class TestMessagesApi(unittest.TestCase):

def setUp(self) -> None:
configuration = Configuration(
username=BW_USERNAME,
password=BW_PASSWORD,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_mfa_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class TestMFAApi(unittest.TestCase):

def setUp(self) -> None:
configuration = Configuration(
username=BW_USERNAME,
password=BW_PASSWORD,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_multi_channel_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ class TestMultiChannelApi(unittest.TestCase):

def setUp(self) -> None:
configuration = Configuration(
username=BW_USERNAME,
password=BW_PASSWORD,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_phone_number_lookup_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ class TestPhoneNumberLookupApi(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
configuration = Configuration(
client_id=BW_CLIENT_ID,
client_secret=BW_CLIENT_SECRET,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_recordings_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class TestRecordingsApi(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
configuration = Configuration(
client_id=BW_CLIENT_ID,
client_secret=BW_CLIENT_SECRET,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_statistics_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class TestStatisticsApi(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
configuration = Configuration(
client_id=BW_CLIENT_ID,
client_secret=BW_CLIENT_SECRET,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_toll_free_verification_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class TestTollFreeVerificationApi(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
configuration = Configuration(
client_id=BW_CLIENT_ID,
client_secret=BW_CLIENT_SECRET,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down
3 changes: 1 addition & 2 deletions test/unit/api/test_transcriptions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class TestTranscriptionsApi(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
configuration = Configuration(
client_id=BW_CLIENT_ID,
client_secret=BW_CLIENT_SECRET,
access_token='abcd1234',
host='http://127.0.0.1:4010',
ignore_operation_servers=True
)
Expand Down