Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Et9797 opened this issue May 22, 2024 · 1 comment
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@Et9797
Copy link

Et9797 commented May 22, 2024

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)
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. label May 22, 2024
@tswast tswast added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label May 22, 2024
@tswast
Copy link
Collaborator

tswast commented May 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants