Problem
User or application can not access data in a BigQuery view with Access Denied or Unauthorized errors.
Environment
- BigQuery
Solution
- Make sure the user or service account has at least BigQuery Data Viewer (roles/bigquery.dataViewer) access on the 'destination' view they want to access.
- One of the following is true:
- The source dataset/table/other view containing the data exposed by the view (which is potentially in another project) shares the data with the project containing the view via BigQuery > Select source dataset/table/view > Share > Authorized views > Add the destination view.
- The user was added to the source dataset/table/other view with at least BigQuery Data Viewer role.
If the source of data is another view, the check needs to be applied recursively.
Cause
Access to data in a View must be granted at least to the project containing the view via Authorized Views or to the user/service account performing the query by adding them as viewer to the source dataset/table/view.