Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.
This repository was archived by the owner on May 12, 2026. It is now read-only.

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

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

Activity

  1. dheerajpanangat commented on Sep 8, 2021

    @dheerajpanangat
    ContributorAuthor

    Created a pull request for the same.
    Can we please review : #732 ?

    Thanks,

  2. justinwhite commented on Sep 15, 2021

    @justinwhite

    Dheeraj - looks like you need to sign the CLA for them to look at the pull request: #732 (comment)

  3. added
    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.
    on Sep 16, 2021
  4. xfthhxk commented on Oct 29, 2021

    @xfthhxk

    This is an issue for me as well. Is there a workaround?

  5. dheerajpanangat commented on Nov 18, 2021

    @dheerajpanangat
    ContributorAuthor

    This is an issue for me as well. Is there a workaround?

    Awaiting for the pull request to be merged : #732
    Meanwhile I have moved the classes to my project and using the fixed version to run it on local machine.

  6. self-assigned this
    on Nov 22, 2021
  7. added
    🚨This issue needs some love.
    and removed
    🚨This issue needs some love.
    on Feb 20, 2022
  8. added a commit that references this issue on Mar 15, 2022
    7dcd549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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