I am trying to run a simple query on Google BigQuery via a python script, but am getting the below error that my service account is missing bigquery.jobs.create
permission.
My service Account has the following roles applied:
- Owner
- BigQuery Admin
- BigQuery Job User
I've also tried creating a custom role with bigquery.jobs.create
and applying that to the service account, but still consistently get this error. What am I doing wrong?
from google.cloud import bigquery
from google.oauth2 import service_account
project_id = "my-test-project"
credentials = service_account.Credentials.from_service_account_file("credentials.json")
client = bigquery.Client(
credentials=credentials,
project=project_id
)
print(client.project) # returns "my-test-project"
query = client.query("select 1 as test;")
Access Denied: Project my-test-project: The user my-service-account @ my-test-project. iam.gserviceaccount.com does not have bigquery.jobs.create permission in project my-test-project.
client = bigquery.Client.from_service_account_json("credentials.json")
? I doubt it will make a difference, but just curious. – Dascienz