GeezerVison is showing github.com — Exception: API Key and the authentication credential are from different projects · Issue #1405 · googleapis/google-cloud-java
Exception: API Key and the authentication credential are from different projects #1405Labels api: translationIssues related to the Cloud Translation API API.authtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DescriptionIf 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"
}
Activitygarrettjonesgoogle commented on Dec 9, 2016 We are seeing this in the AppVeyor integration test - looks like an important issue to address. lesv commented on Dec 9, 2016 GOOGLE_APPLICATION_CREDENTIALS should override gcloud auth application-default login gguuss commented on Dec 10, 2016 ContributorAuthor More actions @lesv This is happening when you are using the GOOGLE_API_KEY environment variable alongside the GOOGLE_APPLICATION_CREDENTIALS variable. I am not sure whether the default application credentials are affecting the conflict. lesv commented on Feb 23, 2017 It doesn't sound like this will block GA for Storage, Logging, PubSub, Datastore, or BigQuery tcoffee-google commented on Jun 22, 2017
MetadataMetadataapi: translationIssues related to the Cloud Translation API API.authtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DevelopmentNo branches or pull requestsIssue actions
|