Skip to content

Allow passing path to keyfile to use for credentials #2143

@sundewei

Description

@sundewei

@garrettjonesgoogle
Hi,
I was informed to create a ticket for Java from an existing ticket which was for Ruby:
googleapis/gapic-generator#1324

Currently I am trying to create a custom metric in Java but was not able to find out how to create the MetricServiceClient object from the json keyfile.

If you can provide me a Java example of doing it, that'd ok for now....many thanks

Dewei

Below is my code:
Line 1
CredentialsProvider credentialsProvider = FixedCredentialsProvider.create( ServiceAccountCredentials.fromStream(new FileInputStream(gcpJsonKeyFilePath)));
Line 2
final MetricServiceClient client = MetricServiceClient.create((MetricServiceSettings) MetricServiceSettings.newBuilder().setCredentialsProvider(credentialsProvider).build());

Here is the error message:

Exception in thread "main" java.lang.IllegalStateException: Missing required properties: totalTimeout initialRetryDelay retryDelayMultiplier maxRetryDelay initialRpcTimeout rpcTimeoutMultiplier maxRpcTimeout

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions