googleapis/python-bigquery-dataframes

Add service account authentication in bigframes `read_gbq` method like in pandas-gbq package

Et9797 opened this issue · 1 comments

Very simple in pandas-gbq:

from google.oauth2 import service_account
import pandas_gbq

credentials = service_account.Credentials.from_service_account_file('
    path/to/key.json'
)
df = pandas_gbq.read_gbq(query, project_id="YOUR-PROJECT-ID", credentials=credentials)

Thanks for the feature request!

This is currently possible using the bigframes.options.bigquery.credentials property:

from google.oauth2 import service_account
import bigframes.pandas as bpd

credentials = service_account.Credentials.from_service_account_file('
    path/to/key.json'
)
bpd.options.bigquery.project = "YOUR-PROJECT-ID"
bpd.options.bigquery.credentials = credentials
df = bpd.read_gbq(query)

That said, I think it makes sense to try and stay compatible with pandas-gbq usage. We already do something similar to this for autodetecting the location when read_gbq is the first call in a new BigQuery DataFrames session.