Skip to content

BigQuery/Storage - ImpersonatedCredentials fails when trying to get Service #731

@dheerajpanangat

Description

@dheerajpanangat

Environment details

  1. Specify the API at the beginning of the title. For example, "BigQuery: ...").
    General, Core, and Other are also allowed as types
  2. OS type and version: MAC OS Big Sur 11.5.2
  3. Java version: 8
  4. google-auth-library version(s): 1.1.0

Steps to reproduce

  1. Impersonate the account : gcloud config set auth/impersonate_service_account
  2. Set application default credentials : gcloud auth application-default login

Code example

import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.bigquery.BigQuery;

GoogleCredentials credentials = ComputeEngineCredentials.getApplicationDefault();
BigQuery bigquery = BigQueryOptions.newBuilder().setProjectId(projectId).setCredentials(credentials).build()
				.getService();
// example

Stack trace

Caused by: java.lang.ClassCastException: class com.google.common.collect.SingletonImmutableSet cannot be cast to class java.util.List (com.google.common.collect.SingletonImmutableSet is in unnamed module of loader 'app'; java.util.List is in module java.base of loader 'bootstrap')
	at com.google.auth.oauth2.ImpersonatedCredentials.createScoped(ImpersonatedCredentials.java:367)
	at com.google.cloud.ServiceOptions.getScopedCredentials(ServiceOptions.java:596)
	at com.google.cloud.http.HttpTransportOptions.getHttpRequestInitializer(HttpTransportOptions.java:145)
	at com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.<init>(HttpBigQueryRpc.java:105)
	at com.google.cloud.bigquery.BigQueryOptions$DefaultBigQueryRpcFactory.create(BigQueryOptions.java:56)
	at com.google.cloud.bigquery.BigQueryOptions$DefaultBigQueryRpcFactory.create(BigQueryOptions.java:50)
	at com.google.cloud.ServiceOptions.getRpc(ServiceOptions.java:560)
	at com.google.cloud.bigquery.BigQueryOptions.getBigQueryRpcV2(BigQueryOptions.java:125)
	at com.google.cloud.bigquery.BigQueryImpl.<init>(BigQueryImpl.java:249)
	at com.google.cloud.bigquery.BigQueryOptions$DefaultBigQueryFactory.create(BigQueryOptions.java:46)
	at com.google.cloud.bigquery.BigQueryOptions$DefaultBigQueryFactory.create(BigQueryOptions.java:40)
	at com.google.cloud.ServiceOptions.getService(ServiceOptions.java:540)

External references such as API reference guides

  • NA

Any additional information below

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: bigqueryIssues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions