Skip to content

google.auth.default ignores provided scopes when application default credentials are an authorized user. #805

Closed
@ipear3

Description

@ipear3

Environment details

  • OS: macOS Big Sur version 11.4
  • Python version: 3.8.2
  • pip version: 21.1.3
  • google-auth version: 1.33.1

Steps to reproduce

  1. Confirm application default credentials are an authorized user (env var GOOGLE_APPLICATION_CREDENTIALS is not set, and gcloud auth application-default login has been run and quota project has been added to ADC)
  2. Run the code from the guide "Querying Drive Data"
from google.cloud import bigquery
import google.auth

# Create credentials with Drive & BigQuery API scopes.
# Both APIs must be enabled for your project before running this code.
credentials, project = google.auth.default(
  scopes=[
      "https://www.googleapis.com/auth/drive",
      "https://www.googleapis.com/auth/bigquery",
  ]
)

# Construct a BigQuery client object.
client = bigquery.Client(credentials=credentials, project=project)
  1. Inspect the credentials and client variables. Neither will contain the drive scope provided.
    OR
  2. Attempt to run a query that references a drive-sourced table and receive the error: google.api_core.exceptions.Forbidden: 403 Access Denied: BigQuery BigQuery: Permission denied while getting Drive credentials.

The user I am authenticating as has viewer permissions for the sheet in question.

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the googleapis/python-bigquery API.type: docsImprovement to the documentation for an API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions