-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Closed
Copy link
Labels
api: translationIssues related to the Cloud Translation API API.Issues related to the Cloud Translation API API.authtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Milestone
Description
If you have multiple sets of valid credentials configured in your Java environment, the Cloud library will not resolve between the two.
Repro steps
- Configure client library for API key:
export GOOGLE_API_KEY=SOME_VALID_DEVELOPER_KEY - Configure client library for valid credentials from separate project:
export GOOGLE_APPLICATION_CREDENTIALS=./creds.json - Run java sample, e.g. from github.com/GoogleCloudPlatform/java-docs-samples/translate...
mvn clean compile assembly:single
JAR_FILE=target/translate-1.0-jar-with-dependencies.jar
INPUT="A quick brown fox jumped over a lazy dog."
SOURCE_LANG="en"
TARGET_LANG="fr"
java -jar $JAR_FILE translate "$INPUT" $SOURCE_LANG $TARGET_LANG
Expected outcome
Client library warns developer but uses an access token from the service account.
Actual outcome
Client library fails, throwing exception and crashing app.
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "The API Key and the authentication credential are from different projects.",
"reason" : "badRequest"
} ],
"message" : "The API Key and the authentication credential are from different projects.",
"status" : "INVALID_ARGUMENT"
}
Metadata
Metadata
Assignees
Labels
api: translationIssues related to the Cloud Translation API API.Issues related to the Cloud Translation API API.authtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.