@@ -8,6 +8,7 @@ import { CreateUserBindingDto } from 'omniboxd/user/dto/create-user-binding.dto'
88import { Injectable , Logger , HttpStatus } from '@nestjs/common' ;
99import { AppException } from 'omniboxd/common/exceptions/app.exception' ;
1010import { I18nService } from 'nestjs-i18n' ;
11+ import { fetchWithRetry } from 'omniboxd/utils/fetch-with-retry' ;
1112
1213interface GoogleTokenResponse {
1314 access_token : string ;
@@ -103,19 +104,22 @@ export class GoogleService {
103104 ) ;
104105 }
105106
106- const tokenResponse = await fetch ( `${ this . googleOAuthAPIBaseUrl } /token` , {
107- method : 'POST' ,
108- headers : {
109- 'Content-Type' : 'application/x-www-form-urlencoded' ,
107+ const tokenResponse = await fetchWithRetry (
108+ `${ this . googleOAuthAPIBaseUrl } /token` ,
109+ {
110+ method : 'POST' ,
111+ headers : {
112+ 'Content-Type' : 'application/x-www-form-urlencoded' ,
113+ } ,
114+ body : new URLSearchParams ( {
115+ client_id : this . clientId ,
116+ client_secret : this . clientSecret ,
117+ code : code ,
118+ grant_type : 'authorization_code' ,
119+ redirect_uri : this . redirectUri ,
120+ } ) ,
110121 } ,
111- body : new URLSearchParams ( {
112- client_id : this . clientId ,
113- client_secret : this . clientSecret ,
114- code : code ,
115- grant_type : 'authorization_code' ,
116- redirect_uri : this . redirectUri ,
117- } ) ,
118- } ) ;
122+ ) ;
119123
120124 if ( ! tokenResponse . ok ) {
121125 const providerName = this . i18n . t ( 'auth.providers.google' ) ;
@@ -139,7 +143,7 @@ export class GoogleService {
139143 ) ;
140144 }
141145
142- const userInfoResponse = await fetch (
146+ const userInfoResponse = await fetchWithRetry (
143147 `${ this . googleAPIBaseUrl } /oauth2/v3/userinfo` ,
144148 {
145149 headers : { Authorization : `Bearer ${ tokenData . access_token } ` } ,
0 commit comments