@@ -669,6 +669,7 @@ export class OAuth2Client extends AuthClient {
669
669
code_verifier : options . codeVerifier ,
670
670
} ;
671
671
const res = await this . transporter . request < CredentialRequest > ( {
672
+ ...OAuth2Client . RETRY_CONFIG ,
672
673
method : 'POST' ,
673
674
url,
674
675
data : querystring . stringify ( values ) ,
@@ -733,6 +734,7 @@ export class OAuth2Client extends AuthClient {
733
734
try {
734
735
// request for new token
735
736
res = await this . transporter . request < CredentialRequest > ( {
737
+ ...OAuth2Client . RETRY_CONFIG ,
736
738
method : 'POST' ,
737
739
url,
738
740
data : querystring . stringify ( data ) ,
@@ -956,6 +958,7 @@ export class OAuth2Client extends AuthClient {
956
958
callback ?: BodyResponseCallback < RevokeCredentialsResult >
957
959
) : GaxiosPromise < RevokeCredentialsResult > | void {
958
960
const opts : GaxiosOptions = {
961
+ ...OAuth2Client . RETRY_CONFIG ,
959
962
url : this . getRevokeTokenURL ( token ) . toString ( ) ,
960
963
method : 'POST' ,
961
964
} ;
@@ -1024,7 +1027,7 @@ export class OAuth2Client extends AuthClient {
1024
1027
1025
1028
protected async requestAsync < T > (
1026
1029
opts : GaxiosOptions ,
1027
- retry = false
1030
+ reAuthRetried = false
1028
1031
) : Promise < GaxiosResponse < T > > {
1029
1032
let r2 : GaxiosResponse ;
1030
1033
try {
@@ -1078,11 +1081,16 @@ export class OAuth2Client extends AuthClient {
1078
1081
this . refreshHandler ;
1079
1082
const isReadableStream = res . config . data instanceof stream . Readable ;
1080
1083
const isAuthErr = statusCode === 401 || statusCode === 403 ;
1081
- if ( ! retry && isAuthErr && ! isReadableStream && mayRequireRefresh ) {
1084
+ if (
1085
+ ! reAuthRetried &&
1086
+ isAuthErr &&
1087
+ ! isReadableStream &&
1088
+ mayRequireRefresh
1089
+ ) {
1082
1090
await this . refreshAccessTokenAsync ( ) ;
1083
1091
return this . requestAsync < T > ( opts , true ) ;
1084
1092
} else if (
1085
- ! retry &&
1093
+ ! reAuthRetried &&
1086
1094
isAuthErr &&
1087
1095
! isReadableStream &&
1088
1096
mayRequireRefreshWithNoRefreshToken
@@ -1157,6 +1165,7 @@ export class OAuth2Client extends AuthClient {
1157
1165
*/
1158
1166
async getTokenInfo ( accessToken : string ) : Promise < TokenInfo > {
1159
1167
const { data} = await this . transporter . request < TokenInfoRequest > ( {
1168
+ ...OAuth2Client . RETRY_CONFIG ,
1160
1169
method : 'POST' ,
1161
1170
headers : {
1162
1171
'Content-Type' : 'application/x-www-form-urlencoded' ,
@@ -1222,7 +1231,10 @@ export class OAuth2Client extends AuthClient {
1222
1231
throw new Error ( `Unsupported certificate format ${ format } ` ) ;
1223
1232
}
1224
1233
try {
1225
- res = await this . transporter . request ( { url} ) ;
1234
+ res = await this . transporter . request ( {
1235
+ ...OAuth2Client . RETRY_CONFIG ,
1236
+ url,
1237
+ } ) ;
1226
1238
} catch ( e ) {
1227
1239
if ( e instanceof Error ) {
1228
1240
e . message = `Failed to retrieve verification certificates: ${ e . message } ` ;
@@ -1290,7 +1302,10 @@ export class OAuth2Client extends AuthClient {
1290
1302
const url = this . endpoints . oauth2IapPublicKeyUrl . toString ( ) ;
1291
1303
1292
1304
try {
1293
- res = await this . transporter . request ( { url} ) ;
1305
+ res = await this . transporter . request ( {
1306
+ ...OAuth2Client . RETRY_CONFIG ,
1307
+ url,
1308
+ } ) ;
1294
1309
} catch ( e ) {
1295
1310
if ( e instanceof Error ) {
1296
1311
e . message = `Failed to retrieve verification certificates: ${ e . message } ` ;
0 commit comments