Skip to content

Commit 79cb63e

Browse files
authored
SWI-8858 Add OAuth (#266)
* SWI-8858 Add OAuth * restore test files * revert pyproject.toml * regenerate * config * config mustache * fix tn lookup test * update oauth and tests * add secret * update readme * fix print * remove print * update tests * unit tests * update template * rename expiration * remove print
1 parent ab08856 commit 79cb63e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1750
-304
lines changed

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }}
1414
BW_USERNAME: ${{ secrets.BW_USERNAME }}
1515
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
16+
BW_CLIENT_ID: ${{ secrets.BW_CLIENT_ID }}
17+
BW_CLIENT_SECRET: ${{ secrets.BW_CLIENT_SECRET }}
1618
BW_USERNAME_FORBIDDEN: ${{ secrets.BW_USERNAME_FORBIDDEN }}
1719
BW_PASSWORD_FORBIDDEN: ${{ secrets.BW_PASSWORD_FORBIDDEN }}
1820
BW_VOICE_APPLICATION_ID: ${{ secrets.BW_VOICE_APPLICATION_ID }}

.github/workflows/test-pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ env:
1313
BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }}
1414
BW_USERNAME: ${{ secrets.BW_USERNAME }}
1515
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
16+
BW_CLIENT_ID: ${{ secrets.BW_CLIENT_ID }}
17+
BW_CLIENT_SECRET: ${{ secrets.BW_CLIENT_SECRET }}
1618
BW_USERNAME_FORBIDDEN: ${{ secrets.BW_USERNAME_FORBIDDEN }}
1719
BW_PASSWORD_FORBIDDEN: ${{ secrets.BW_PASSWORD_FORBIDDEN }}
1820
BW_VOICE_APPLICATION_ID: ${{ secrets.BW_VOICE_APPLICATION_ID }}

.github/workflows/test-smoke.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ env:
2727
OPERATING_SYSTEM: ubuntu
2828
BW_USERNAME: ${{ secrets.BW_USERNAME }}
2929
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
30+
BW_CLIENT_ID: ${{ secrets.BW_CLIENT_ID }}
31+
BW_CLIENT_SECRET: ${{ secrets.BW_CLIENT_SECRET }}
3032
BW_USERNAME_FORBIDDEN: ${{ secrets.BW_USERNAME_FORBIDDEN }}
3133
BW_PASSWORD_FORBIDDEN: ${{ secrets.BW_PASSWORD_FORBIDDEN }}
3234
USER_NUMBER: ${{ secrets.USER_NUMBER }}

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ configuration = bandwidth.Configuration(
7373
password = os.environ["PASSWORD"]
7474
)
7575

76+
# Configure your client ID and secret for OAuth
77+
configuration = bandwidth.Configuration(
78+
client_id = os.environ["CLIENT_ID"],
79+
client_secret = os.environ["CLIENT_SECRET"]
80+
)
81+
7682

7783
# Enter a context with an instance of the API client
7884
with bandwidth.ApiClient(configuration) as api_client:
@@ -337,6 +343,14 @@ Authentication schemes defined for the API:
337343

338344
- **Type**: HTTP basic authentication
339345

346+
<a id="OAuth2"></a>
347+
### OAuth2
348+
349+
- **Type**: OAuth
350+
- **Flow**: application
351+
- **Authorization URL**:
352+
- **Scopes**: N/A
353+
340354

341355
## Author
342356

bandwidth.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ info:
88
99
version: 1.0.0
1010
security:
11+
- OAuth2: []
1112
- Basic: []
1213
tags:
1314
- name: Messages
@@ -8427,6 +8428,12 @@ components:
84278428
84288429
84298430
- Example: `Authorization: Basic ZGVtbZpwQDU1dzByZA==`
8431+
OAuth2:
8432+
type: oauth2
8433+
flows:
8434+
clientCredentials:
8435+
tokenUrl: https://api.bandwidth.com/api/v1/oauth2/token
8436+
scopes: {}
84308437
callbacks:
84318438
inboundCallback:
84328439
'{inboundCallbackUrl}':

bandwidth/api/calls_api.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ def _create_call_serialize(
338338

339339
# authentication setting
340340
_auth_settings: List[str] = [
341-
'Basic'
341+
'Basic',
342+
'OAuth2'
342343
]
343344

344345
return self.api_client.param_serialize(
@@ -641,7 +642,8 @@ def _get_call_state_serialize(
641642

642643
# authentication setting
643644
_auth_settings: List[str] = [
644-
'Basic'
645+
'Basic',
646+
'OAuth2'
645647
]
646648

647649
return self.api_client.param_serialize(
@@ -1048,7 +1050,8 @@ def _list_calls_serialize(
10481050

10491051
# authentication setting
10501052
_auth_settings: List[str] = [
1051-
'Basic'
1053+
'Basic',
1054+
'OAuth2'
10521055
]
10531056

10541057
return self.api_client.param_serialize(
@@ -1382,7 +1385,8 @@ def _update_call_serialize(
13821385

13831386
# authentication setting
13841387
_auth_settings: List[str] = [
1385-
'Basic'
1388+
'Basic',
1389+
'OAuth2'
13861390
]
13871391

13881392
return self.api_client.param_serialize(
@@ -1716,7 +1720,8 @@ def _update_call_bxml_serialize(
17161720

17171721
# authentication setting
17181722
_auth_settings: List[str] = [
1719-
'Basic'
1723+
'Basic',
1724+
'OAuth2'
17201725
]
17211726

17221727
return self.api_client.param_serialize(

bandwidth/api/conferences_api.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ def _download_conference_recording_serialize(
343343

344344
# authentication setting
345345
_auth_settings: List[str] = [
346-
'Basic'
346+
'Basic',
347+
'OAuth2'
347348
]
348349

349350
return self.api_client.param_serialize(
@@ -646,7 +647,8 @@ def _get_conference_serialize(
646647

647648
# authentication setting
648649
_auth_settings: List[str] = [
649-
'Basic'
650+
'Basic',
651+
'OAuth2'
650652
]
651653

652654
return self.api_client.param_serialize(
@@ -964,7 +966,8 @@ def _get_conference_member_serialize(
964966

965967
# authentication setting
966968
_auth_settings: List[str] = [
967-
'Basic'
969+
'Basic',
970+
'OAuth2'
968971
]
969972

970973
return self.api_client.param_serialize(
@@ -1282,7 +1285,8 @@ def _get_conference_recording_serialize(
12821285

12831286
# authentication setting
12841287
_auth_settings: List[str] = [
1285-
'Basic'
1288+
'Basic',
1289+
'OAuth2'
12861290
]
12871291

12881292
return self.api_client.param_serialize(
@@ -1585,7 +1589,8 @@ def _list_conference_recordings_serialize(
15851589

15861590
# authentication setting
15871591
_auth_settings: List[str] = [
1588-
'Basic'
1592+
'Basic',
1593+
'OAuth2'
15891594
]
15901595

15911596
return self.api_client.param_serialize(
@@ -1958,7 +1963,8 @@ def _list_conferences_serialize(
19581963

19591964
# authentication setting
19601965
_auth_settings: List[str] = [
1961-
'Basic'
1966+
'Basic',
1967+
'OAuth2'
19621968
]
19631969

19641970
return self.api_client.param_serialize(
@@ -2289,7 +2295,8 @@ def _update_conference_serialize(
22892295

22902296
# authentication setting
22912297
_auth_settings: List[str] = [
2292-
'Basic'
2298+
'Basic',
2299+
'OAuth2'
22932300
]
22942301

22952302
return self.api_client.param_serialize(
@@ -2620,7 +2627,8 @@ def _update_conference_bxml_serialize(
26202627

26212628
# authentication setting
26222629
_auth_settings: List[str] = [
2623-
'Basic'
2630+
'Basic',
2631+
'OAuth2'
26242632
]
26252633

26262634
return self.api_client.param_serialize(
@@ -2966,7 +2974,8 @@ def _update_conference_member_serialize(
29662974

29672975
# authentication setting
29682976
_auth_settings: List[str] = [
2969-
'Basic'
2977+
'Basic',
2978+
'OAuth2'
29702979
]
29712980

29722981
return self.api_client.param_serialize(

bandwidth/api/media_api.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ def _delete_media_serialize(
322322

323323
# authentication setting
324324
_auth_settings: List[str] = [
325-
'Basic'
325+
'Basic',
326+
'OAuth2'
326327
]
327328

328329
return self.api_client.param_serialize(
@@ -626,7 +627,8 @@ def _get_media_serialize(
626627

627628
# authentication setting
628629
_auth_settings: List[str] = [
629-
'Basic'
630+
'Basic',
631+
'OAuth2'
630632
]
631633

632634
return self.api_client.param_serialize(
@@ -929,7 +931,8 @@ def _list_media_serialize(
929931

930932
# authentication setting
931933
_auth_settings: List[str] = [
932-
'Basic'
934+
'Basic',
935+
'OAuth2'
933936
]
934937

935938
return self.api_client.param_serialize(
@@ -1345,7 +1348,8 @@ def _upload_media_serialize(
13451348

13461349
# authentication setting
13471350
_auth_settings: List[str] = [
1348-
'Basic'
1351+
'Basic',
1352+
'OAuth2'
13491353
]
13501354

13511355
return self.api_client.param_serialize(

bandwidth/api/messages_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ def _create_message_serialize(
344344

345345
# authentication setting
346346
_auth_settings: List[str] = [
347-
'Basic'
347+
'Basic',
348+
'OAuth2'
348349
]
349350

350351
return self.api_client.param_serialize(
@@ -1088,7 +1089,8 @@ def _list_messages_serialize(
10881089

10891090
# authentication setting
10901091
_auth_settings: List[str] = [
1091-
'Basic'
1092+
'Basic',
1093+
'OAuth2'
10921094
]
10931095

10941096
return self.api_client.param_serialize(

bandwidth/api/mfa_api.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ def _generate_messaging_code_serialize(
326326

327327
# authentication setting
328328
_auth_settings: List[str] = [
329-
'Basic'
329+
'Basic',
330+
'OAuth2'
330331
]
331332

332333
return self.api_client.param_serialize(
@@ -630,7 +631,8 @@ def _generate_voice_code_serialize(
630631

631632
# authentication setting
632633
_auth_settings: List[str] = [
633-
'Basic'
634+
'Basic',
635+
'OAuth2'
634636
]
635637

636638
return self.api_client.param_serialize(
@@ -937,7 +939,8 @@ def _verify_code_serialize(
937939

938940
# authentication setting
939941
_auth_settings: List[str] = [
940-
'Basic'
942+
'Basic',
943+
'OAuth2'
941944
]
942945

943946
return self.api_client.param_serialize(

0 commit comments

Comments
 (0)