Skip to content

setCredentials not setting projectId on ServiceOptions builder #936

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions