googleapis / googleapis/google-cloud-java

Cloud Function Service Client load credentials through String

Open
#10,005 1 comment 0 reactions 0 assignees View on GitHub
auth priority: p2 type: feature request
Dominant language
Java
Stars
2.1k
Forks
1.2k
Avg merge
1d 23h
Merged PRs (30d)
154

Description

Thanks for stopping by to let us know something could be better!

**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.

**Is your feature request related to a problem? Please describe.**
I want to load my GCP credentials for the Cloud Function Service Client thru env variable of json string (that contains the contents of GCP credentials) but I can't find it [here](https://github.com/googleapis/google-cloud-java/blob/0d6459c4c189f572e07640b3789f0cc8cd2a2a45/java-functions/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/CloudFunctionsServiceClient.java#L151). Is it not supported?
```json
{
"type": "external_account",
"audience": "//iam.googleapis.com/projects/blabla/locations/blabla/workloadIdentityPools/...",
"subject_token_type": "urn:ietf:params:aws:token-type:aws4_request",
"token_url": "https://sts.googleapis.com/v1/token",
"credential_source": {
"environment_id": "aws1",
"region_url": "http://someip/latest/meta-data/placement/availability-zone",
"url": "http://someip/latest/meta-data/iam/security-credentials",
"regional_cred_verification_url": "https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15"
},
"service_account_impersonation_url": "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/blablabla"
}
```

**Describe the solution you'd like**
I would like a constructor for this client that uses a json string of the contents of the credentials file.
```java
### JsonNode type
public static final CloudFunctionsServiceClient create(JsonNode credentials) throws IOException {
return create(CloudFunctionsServiceSettings.newBuilder().build());
}

### String type
public static final CloudFunctionsServiceClient create(String jsonCredentials) throws IOException {
return create(CloudFunctionsServiceSettings.newBuilder().build());
}
```

**Describe alternatives you've considered**
Used the file and the credential json file path set as an environment variable, but our security measures dictate that no credentials are to be saved as files.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.