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();