Skip to content
Advertisement

Python Google BigQuery, how to authenticate without JSON file?

I have a JSON file with BigQuery credentials. To connect with Python to BigQuery I need to give the file path in service_account.

JavaScript

The JSON looks like a dictionary:

JavaScript

I don’t want to use a file in the project. Is there a way instead of a path to file to use JSON string from the dictionary to connect to BigQuery?

Advertisement

Answer

you can use the constructor service_account.Credentials.from_service_account_info(sa_dict) instead.

Docs

be careful if you upload the code to a public repo though. One of the reasons to use a separate JSON file is so you can exclude it from repos.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement