@@ -566,26 +566,29 @@ func NewLocalStorage(
566566) (* LocalStorage , error ) {
567567 // Set up Request Modifiers
568568 clientOptions := []managementClient.ClientOption {}
569- if authzEnabled {
570- var googleClient * http.Client
571- var err error
572- // Init Google client for Authz. When using a non-empty googleApplicationCredentialsEnvVar that contains a file
573- // path to a credentials file, the credentials file MUST contain a Google SERVICE ACCOUNT for authentication to
574- // work correctly
575- if filepath := os .Getenv (googleApplicationCredentialsEnvVar ); filepath != "" {
576- googleClient , err = auth .InitGoogleClientFromCredentialsFile (context .Background (), filepath )
577- } else {
578- googleClient , err = auth .InitGoogleClient (context .Background ())
579- }
580- if err != nil {
581- return nil , err
582- }
583569
584- clientOptions = append (
585- clientOptions ,
586- managementClient .WithHTTPClient (googleClient ),
587- )
570+ httpClient := http .DefaultClient
571+ var googleClient * http.Client
572+ var err error
573+ // Init Google client for Authz. When using a non-empty googleApplicationCredentialsEnvVar that contains a file
574+ // path to a credentials file, the credentials file MUST contain a Google SERVICE ACCOUNT for authentication to
575+ // work correctly
576+ if filepath := os .Getenv (googleApplicationCredentialsEnvVar ); filepath != "" {
577+ googleClient , err = auth .InitGoogleClientFromCredentialsFile (context .Background (), filepath )
578+ } else {
579+ googleClient , err = auth .InitGoogleClient (context .Background ())
588580 }
581+
582+ if err == nil {
583+ httpClient = googleClient
584+ } else {
585+ log .Println ("Google default credential not found. Fallback to HTTP default client" )
586+ }
587+
588+ clientOptions = append (
589+ clientOptions ,
590+ managementClient .WithHTTPClient (httpClient ),
591+ )
589592 xpClient , err := managementClient .NewClientWithResponses (xpServer , clientOptions ... )
590593 if err != nil {
591594 return nil , err
0 commit comments