Skip to content

setCredentials not setting projectId on ServiceOptions builder #936

@williamlang

Description

@williamlang

In which file did you encounter the issue?

jdt://contents/google-cloud-core-1.12.0.jar/com.google.cloud/ServiceOptions.class

Did you change the file? If so, how?

No

Describe the issue

I used the example here:

https://cloud.google.com/bigquery/docs/authentication/service-account-file

 // Instantiate a client.
  BigQuery bigquery = BigQueryOptions.newBuilder().setCredentials(credentials).build().getService();

I verified that the properties set on the credentials object are not null.

The ServiceOptions builder object has a property called projectId that does not get set, despite the fact that the credentials property is set on the builder.

Either two fixes need to happen:

ServiceOptions.class:244 becomes
projectId = builder.projectId != null ? builder.getCredentials().getProjectId() : getDefaultProject();

Or,

setCredentials must set the projectId property on the builder.

Metadata

Metadata

Assignees

No one assigned

    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