Google Natural Language API Java LanguageServiceClient how to use api key

198 Views Asked by At

I am trying to categorize texts by using the google Language API with the provided Java client. The code is in Scala and it 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 fails to authorize though, is there a way to authorize with the API key I have created?

0

There are 0 best solutions below