Hi
How can I configure Apikey in my Java class. I am using google-cloud-translate 1.12.0 in Maven Entry. Appreciate any help, Thanks in advance
Also, as a start I am using one of google GIT published code
/**
* Detect the language of input text.
*
* @param sourceText
* source text to be detected for language
* @param out
* print stream
*/
public static void detectLanguage(String sourceText, PrintStream out) {
Translate translate = createTranslateService();
List<Detection> detections = translate.detect(ImmutableList.of(sourceText));
System.out.println("Language(s) detected:");
for (Detection detection : detections) {
out.printf("\t%s\n", detection);
}
}
/**
* Create Google Translate API Service.
*
* @return Google Translate Service
*/
public static Translate createTranslateService() {
return TranslateOptions.newBuilder().build().getService();
}
public static void main(String[] args) {
detectLanguage("Hello", System.out);
}
Error it gives
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"errors": [
{
"message": "The request is missing a valid API key.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}