Google Natural Language API Java LanguageServiceClient how to use api key

I am trying to classify texts using the Google language API with the provided Java client. The code is in Scala and looks like this:

val language = LanguageServiceClient.create()
val doc = Document.newBuilder.setGcsContentUri(draftBody).setType(Type.PLAIN_TEXT).build
val request = ClassifyTextRequest.newBuilder.setDocument(doc).build
val response = language.classifyText(request)

The client will not log in, is there a way to log in using the API key I created?

+4
source share

Source: https://habr.com/ru/post/1690232/


All Articles