Skip to content

Commit

Permalink
!hotfix: gcp credentials config
Browse files Browse the repository at this point in the history
  • Loading branch information
daeun084 committed Dec 3, 2024
1 parent 4196c89 commit 0ae65ff
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@

import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.language.v1.LanguageServiceSettings;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;

import java.io.IOException;

@Slf4j
@Configuration
public class GoogleNaturalLanguageConfig {
@Value("classpath:nlp.json")
Resource gcsCredentials;
@Value("${GCP_CREDENTIALS_LOCATION}")
Resource gcpCredentials;

@Bean
public LanguageServiceSettings languageServiceSettings() {
try {
log.info("Loading Google Natural Language Service");
return LanguageServiceSettings.newBuilder()
.setCredentialsProvider(() ->
GoogleCredentials.fromStream(gcsCredentials.getInputStream()))
GoogleCredentials.fromStream(gcpCredentials.getInputStream()))
.build();
} catch (IOException e) {
throw new RuntimeException("Failed to initialize LanguageServiceSettings", e);
Expand Down

0 comments on commit 0ae65ff

Please sign in to comment.