Skip to content

Commit 0f9720c

Browse files
committed
add oauth
1 parent b586dd7 commit 0f9720c

35 files changed

+799
-98
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
1515
hs_err_pid*
1616

17+
*.prefs
18+
1719
# build files
1820
**/target
1921
target

.openapi-generator/FILES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ src/main/java/com/bandwidth/sdk/auth/ApiKeyAuth.java
205205
src/main/java/com/bandwidth/sdk/auth/Authentication.java
206206
src/main/java/com/bandwidth/sdk/auth/HttpBasicAuth.java
207207
src/main/java/com/bandwidth/sdk/auth/HttpBearerAuth.java
208+
src/main/java/com/bandwidth/sdk/auth/OAuth.java
209+
src/main/java/com/bandwidth/sdk/auth/OAuthFlow.java
210+
src/main/java/com/bandwidth/sdk/auth/OAuthOkHttpClient.java
211+
src/main/java/com/bandwidth/sdk/auth/RetryingOAuth.java
208212
src/main/java/com/bandwidth/sdk/model/AbstractOpenApiSchema.java
209213
src/main/java/com/bandwidth/sdk/model/AccountStatistics.java
210214
src/main/java/com/bandwidth/sdk/model/AdditionalDenialReason.java

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ public class Example {
9898
Basic.setUsername("YOUR USERNAME");
9999
Basic.setPassword("YOUR PASSWORD");
100100

101+
// Configure OAuth2 access token for authorization: OAuth2
102+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
103+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
104+
101105
CallsApi apiInstance = new CallsApi(defaultClient);
102106
String accountId = "9900000"; // String | Your Bandwidth Account ID.
103107
CreateCall createCall = new CreateCall(); // CreateCall | JSON object containing information to create an outbound call
@@ -341,6 +345,14 @@ Authentication schemes defined for the API:
341345

342346
- **Type**: HTTP basic authentication
343347

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

345357
## Recommendation
346358

api/openapi.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ servers:
1111
- url: /
1212
security:
1313
- Basic: []
14+
- OAuth2: []
1415
tags:
1516
- name: Messages
1617
- name: Media
@@ -14432,4 +14433,10 @@ components:
1443214433
- Example: `Authorization: Basic ZGVtbZpwQDU1dzByZA==`
1443314434
scheme: basic
1443414435
type: http
14436+
OAuth2:
14437+
flows:
14438+
clientCredentials:
14439+
scopes: {}
14440+
tokenUrl: https://api.bandwidth.com/api/v1/oauth2/token
14441+
type: oauth2
1443514442

bandwidth.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ info:
99
version: 1.0.0
1010
security:
1111
- Basic: []
12+
- OAuth2: []
1213
tags:
1314
- name: Messages
1415
- name: Media
@@ -8095,6 +8096,12 @@ components:
80958096
80968097
80978098
- Example: `Authorization: Basic ZGVtbZpwQDU1dzByZA==`
8099+
OAuth2:
8100+
type: oauth2
8101+
flows:
8102+
clientCredentials:
8103+
tokenUrl: https://api.bandwidth.com/api/v1/oauth2/token
8104+
scopes: {}
80988105
callbacks:
80998106
inboundCallback:
81008107
'{inboundCallbackUrl}':

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ dependencies {
113113
implementation 'io.gsonfire:gson-fire:1.9.0'
114114
implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6'
115115
implementation 'org.openapitools:jackson-databind-nullable:0.2.7'
116+
implementation group: 'org.apache.oltu.oauth2', name: 'org.apache.oltu.oauth2.client', version: '1.0.2'
116117
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.18.0'
117118
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
118119
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ lazy val root = (project in file(".")).
1616
"org.apache.commons" % "commons-lang3" % "3.18.0",
1717
"jakarta.ws.rs" % "jakarta.ws.rs-api" % "2.1.6",
1818
"org.openapitools" % "jackson-databind-nullable" % "0.2.7",
19+
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.2",
1920
"io.gsonfire" % "gson-fire" % "1.9.0" % "compile",
2021
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
2122
"com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile",

docs/CallsApi.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public class Example {
3939
Basic.setUsername("YOUR USERNAME");
4040
Basic.setPassword("YOUR PASSWORD");
4141

42+
// Configure OAuth2 access token for authorization: OAuth2
43+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
44+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
45+
4246
CallsApi apiInstance = new CallsApi(defaultClient);
4347
String accountId = "9900000"; // String | Your Bandwidth Account ID.
4448
CreateCall createCall = new CreateCall(); // CreateCall | JSON object containing information to create an outbound call
@@ -69,7 +73,7 @@ public class Example {
6973

7074
### Authorization
7175

72-
[Basic](../README.md#Basic)
76+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
7377

7478
### HTTP request headers
7579

@@ -117,6 +121,10 @@ public class Example {
117121
Basic.setUsername("YOUR USERNAME");
118122
Basic.setPassword("YOUR PASSWORD");
119123

124+
// Configure OAuth2 access token for authorization: OAuth2
125+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
126+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
127+
120128
CallsApi apiInstance = new CallsApi(defaultClient);
121129
String accountId = "9900000"; // String | Your Bandwidth Account ID.
122130
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; // String | Programmable Voice API Call ID.
@@ -147,7 +155,7 @@ public class Example {
147155

148156
### Authorization
149157

150-
[Basic](../README.md#Basic)
158+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
151159

152160
### HTTP request headers
153161

@@ -195,6 +203,10 @@ public class Example {
195203
Basic.setUsername("YOUR USERNAME");
196204
Basic.setPassword("YOUR PASSWORD");
197205

206+
// Configure OAuth2 access token for authorization: OAuth2
207+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
208+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
209+
198210
CallsApi apiInstance = new CallsApi(defaultClient);
199211
String accountId = "9900000"; // String | Your Bandwidth Account ID.
200212
String to = "%2b19195551234"; // String | Filter results by the `to` field.
@@ -237,7 +249,7 @@ public class Example {
237249

238250
### Authorization
239251

240-
[Basic](../README.md#Basic)
252+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
241253

242254
### HTTP request headers
243255

@@ -285,6 +297,10 @@ public class Example {
285297
Basic.setUsername("YOUR USERNAME");
286298
Basic.setPassword("YOUR PASSWORD");
287299

300+
// Configure OAuth2 access token for authorization: OAuth2
301+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
302+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
303+
288304
CallsApi apiInstance = new CallsApi(defaultClient);
289305
String accountId = "9900000"; // String | Your Bandwidth Account ID.
290306
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; // String | Programmable Voice API Call ID.
@@ -316,7 +332,7 @@ null (empty response body)
316332

317333
### Authorization
318334

319-
[Basic](../README.md#Basic)
335+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
320336

321337
### HTTP request headers
322338

@@ -365,6 +381,10 @@ public class Example {
365381
Basic.setUsername("YOUR USERNAME");
366382
Basic.setPassword("YOUR PASSWORD");
367383

384+
// Configure OAuth2 access token for authorization: OAuth2
385+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
386+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
387+
368388
CallsApi apiInstance = new CallsApi(defaultClient);
369389
String accountId = "9900000"; // String | Your Bandwidth Account ID.
370390
String callId = "c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; // String | Programmable Voice API Call ID.
@@ -399,7 +419,7 @@ null (empty response body)
399419
400420
### Authorization
401421
402-
[Basic](../README.md#Basic)
422+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
403423
404424
### HTTP request headers
405425

docs/ConferencesApi.md

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public class Example {
4343
Basic.setUsername("YOUR USERNAME");
4444
Basic.setPassword("YOUR PASSWORD");
4545

46+
// Configure OAuth2 access token for authorization: OAuth2
47+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
48+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
49+
4650
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
4751
String accountId = "9900000"; // String | Your Bandwidth Account ID.
4852
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; // String | Programmable Voice API Conference ID.
@@ -75,7 +79,7 @@ public class Example {
7579

7680
### Authorization
7781

78-
[Basic](../README.md#Basic)
82+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
7983

8084
### HTTP request headers
8185

@@ -123,6 +127,10 @@ public class Example {
123127
Basic.setUsername("YOUR USERNAME");
124128
Basic.setPassword("YOUR PASSWORD");
125129

130+
// Configure OAuth2 access token for authorization: OAuth2
131+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
132+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
133+
126134
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
127135
String accountId = "9900000"; // String | Your Bandwidth Account ID.
128136
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; // String | Programmable Voice API Conference ID.
@@ -153,7 +161,7 @@ public class Example {
153161

154162
### Authorization
155163

156-
[Basic](../README.md#Basic)
164+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
157165

158166
### HTTP request headers
159167

@@ -201,6 +209,10 @@ public class Example {
201209
Basic.setUsername("YOUR USERNAME");
202210
Basic.setPassword("YOUR PASSWORD");
203211

212+
// Configure OAuth2 access token for authorization: OAuth2
213+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
214+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
215+
204216
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
205217
String accountId = "9900000"; // String | Your Bandwidth Account ID.
206218
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; // String | Programmable Voice API Conference ID.
@@ -233,7 +245,7 @@ public class Example {
233245

234246
### Authorization
235247

236-
[Basic](../README.md#Basic)
248+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
237249

238250
### HTTP request headers
239251

@@ -281,6 +293,10 @@ public class Example {
281293
Basic.setUsername("YOUR USERNAME");
282294
Basic.setPassword("YOUR PASSWORD");
283295

296+
// Configure OAuth2 access token for authorization: OAuth2
297+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
298+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
299+
284300
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
285301
String accountId = "9900000"; // String | Your Bandwidth Account ID.
286302
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; // String | Programmable Voice API Conference ID.
@@ -313,7 +329,7 @@ public class Example {
313329

314330
### Authorization
315331

316-
[Basic](../README.md#Basic)
332+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
317333

318334
### HTTP request headers
319335

@@ -361,6 +377,10 @@ public class Example {
361377
Basic.setUsername("YOUR USERNAME");
362378
Basic.setPassword("YOUR PASSWORD");
363379

380+
// Configure OAuth2 access token for authorization: OAuth2
381+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
382+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
383+
364384
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
365385
String accountId = "9900000"; // String | Your Bandwidth Account ID.
366386
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; // String | Programmable Voice API Conference ID.
@@ -391,7 +411,7 @@ public class Example {
391411

392412
### Authorization
393413

394-
[Basic](../README.md#Basic)
414+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
395415

396416
### HTTP request headers
397417

@@ -439,6 +459,10 @@ public class Example {
439459
Basic.setUsername("YOUR USERNAME");
440460
Basic.setPassword("YOUR PASSWORD");
441461

462+
// Configure OAuth2 access token for authorization: OAuth2
463+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
464+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
465+
442466
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
443467
String accountId = "9900000"; // String | Your Bandwidth Account ID.
444468
String name = "my-custom-name"; // String | Filter results by the `name` field.
@@ -477,7 +501,7 @@ public class Example {
477501

478502
### Authorization
479503

480-
[Basic](../README.md#Basic)
504+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
481505

482506
### HTTP request headers
483507

@@ -525,6 +549,10 @@ public class Example {
525549
Basic.setUsername("YOUR USERNAME");
526550
Basic.setPassword("YOUR PASSWORD");
527551

552+
// Configure OAuth2 access token for authorization: OAuth2
553+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
554+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
555+
528556
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
529557
String accountId = "9900000"; // String | Your Bandwidth Account ID.
530558
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; // String | Programmable Voice API Conference ID.
@@ -556,7 +584,7 @@ null (empty response body)
556584

557585
### Authorization
558586

559-
[Basic](../README.md#Basic)
587+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
560588

561589
### HTTP request headers
562590

@@ -604,6 +632,10 @@ public class Example {
604632
Basic.setUsername("YOUR USERNAME");
605633
Basic.setPassword("YOUR PASSWORD");
606634

635+
// Configure OAuth2 access token for authorization: OAuth2
636+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
637+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
638+
607639
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
608640
String accountId = "9900000"; // String | Your Bandwidth Account ID.
609641
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; // String | Programmable Voice API Conference ID.
@@ -638,7 +670,7 @@ null (empty response body)
638670

639671
### Authorization
640672

641-
[Basic](../README.md#Basic)
673+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
642674

643675
### HTTP request headers
644676

@@ -686,6 +718,10 @@ public class Example {
686718
Basic.setUsername("YOUR USERNAME");
687719
Basic.setPassword("YOUR PASSWORD");
688720

721+
// Configure OAuth2 access token for authorization: OAuth2
722+
OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2");
723+
OAuth2.setAccessToken("YOUR ACCESS TOKEN");
724+
689725
ConferencesApi apiInstance = new ConferencesApi(defaultClient);
690726
String accountId = "9900000"; // String | Your Bandwidth Account ID.
691727
String conferenceId = "conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9"; // String | Programmable Voice API Conference ID.
@@ -719,7 +755,7 @@ null (empty response body)
719755

720756
### Authorization
721757

722-
[Basic](../README.md#Basic)
758+
[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2)
723759

724760
### HTTP request headers
725761

0 commit comments

Comments
 (0)