From fe013fa78fe29755e07c2cfa7cc4204bb22886dd Mon Sep 17 00:00:00 2001 From: fishphobiagg Date: Thu, 5 Oct 2023 20:17:16 +0900 Subject: [PATCH] =?UTF-8?q?hotfix:=20GOOGLE=20CREDENTIAL=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95=20[BACK-342]=20Resolves=20:=20is?= =?UTF-8?q?sue=20#342?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- .../domain/google/service/GoogleVisionApiService.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 0e739c3..062da59 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ build/ !gradle/wrapper/gradle-wrapper.jar !**/src/main/**/build/ !**/src/test/**/build/ - +rich-suprstate-386908-7630a2d1a95f.json ### STS ### .apt_generated .classpath diff --git a/src/main/java/com/siliconvalley/domain/google/service/GoogleVisionApiService.java b/src/main/java/com/siliconvalley/domain/google/service/GoogleVisionApiService.java index 7af4c71..a11d66e 100644 --- a/src/main/java/com/siliconvalley/domain/google/service/GoogleVisionApiService.java +++ b/src/main/java/com/siliconvalley/domain/google/service/GoogleVisionApiService.java @@ -8,6 +8,7 @@ import org.springframework.stereotype.Service; import java.io.ByteArrayInputStream; +import java.io.FileInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -19,8 +20,8 @@ @Slf4j public class GoogleVisionApiService { - @Value("${google.service.account.key}") - private String serviceAccountKey; + @Value("${GOOGLE_APPLICATION_CREDENTIALS}") + private String serviceAccountKeyPath; public Map detectLabels(String filePath) { List requests = new ArrayList<>(); @@ -39,9 +40,8 @@ public Map detectLabels(String filePath) { .build(); requests.add(request); - GoogleCredentials credentials = GoogleCredentials.fromStream( - new ByteArrayInputStream(serviceAccountKey.getBytes(StandardCharsets.UTF_8)) - ); + GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(serviceAccountKeyPath)); + ImageAnnotatorSettings settings = ImageAnnotatorSettings.newBuilder() .setCredentialsProvider(FixedCredentialsProvider.create(credentials)) .build();