BigQury Storage Read API, the user does not have 'bigquery.readsessions.create'

Viewed 679

I'm trying to use BigQuery Storage Read API. As far as I can tell, the local script is using the an account, that has Owner role, BigQuery user, and BigQuery read session on the entire project. However, running the code from the local machine yields this error:

google.api_core.exceptions.PermissionDenied: 403 request failed: the user does not have 'bigquery.readsessions.create' permission for 'projects/xyz'

According to the GCP documentation the API is enabled by default. So the only reason I can think of is my script is using the wrong account.

How would you go debugging this issue? Is there a way to know for sure which user/account is running a python code on run time, something like print(user.user_name)

1 Answers

There is a gcloud command to get the current user permissions

$ gcloud projects get-iam-policy [PROJECT_ID]

You can also check the user_email field of your job to find out which user it is using to execute your query.

Example:

{
  # ...
  "user_email": "myemail@company.com",
  "configuration": {
  # ...
  "jobType": QUERY
    },
  },
  "jobReference": {
    "projectId": "my-project",
  # ...
}
Related