How to Configure BigQuery Service Account

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a bigquery service account by creating a non-human identity in Google Cloud. Next, you grant that identity specific roles to read Data or run jobs. Teams often create one shared identity for many apps and analysts. They grant wide project roles so queries do not fail during setup. This shortcut gives every user with the key full reach across all tables. How a bigquery service account works in Google Cloud A service account is a special cloud identity made for apps, scripts, and aut

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up a bigquery service account by creating a non-human identity in Google Cloud. Next, you grant that identity specific roles to read Data or run jobs. Teams often create one shared identity for many apps and analysts. They grant wide project roles so queries do not fail during setup. This shortcut gives every user with the key full reach across all tables.

How a bigquery service account works in Google Cloud

A service account is a special cloud identity made for apps, scripts, and automated tools. It does not belong to a single person on your team. Instead, workloads use it to log in and run queries without human steps.

Cloud admins control this identity through Identity and Access Management roles. You bind roles at the project, dataset, or table level. A job role lets the identity submit queries and use compute slots. A data role lets the identity read rows or write new tables. Both roles must work together before any query can run and return data.

To log in from outside Google Cloud, teams often download a static JSON key file. The app reads this file and trades it for a short access token. If your app runs inside Google Cloud, it can skip key files. It uses attached identities or workload identity federation to get tokens on the fly.

Choosing between project roles and dataset roles

Many teams attach roles at the project level to save time during setup. A project role applies to every dataset and table inside that cloud project. If you add a sensitive table later, the account can read it right away.

Dataset roles offer a safer way to limit what an app can read. You grant the job role on the project so the app can run queries. Then you grant data read roles only on the exact datasets the app needs. This keeps finance or user tables safe from general reporting scripts.

You can also set rules on single tables or specific views. This helps when one dataset holds both public metrics and private records. Admins must plan these boundaries before teams put apps into production.

Service-to-Service Authentication + Service Account Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Where native cloud permissions fall short

Native cloud roles do a good job of deciding who can log in. They also control which datasets or tables an identity can open. Once the identity passes that check, the cloud role steps out of the way.

This leaves a big gap during day-to-day data work. First, downloaded JSON keys live on laptops and inside build servers for months. Anyone who copies that file gets the exact same cloud access. Audit logs only show the shared account name, not the person who ran the query.

Second, static roles cannot inspect the SQL statement itself in flight. A role that allows table reads will return every row and column requested by default. It will not rewrite emails, phone numbers, or card numbers in the query results. It also cannot pause a risky delete command for human approval before it runs.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits inline in the protocol beside the service as an open-source proxy, a sidecar for your database or API. On every production query an agent or human runs, hoop.dev decides whether to pass, mask, block, or escalate it for review.

Before a query runs, hoop.dev guardrails check the statement against your rules, an AI Analyzer you configure can score intent or hold risky calls for human approval, and hoop.dev data masking rewrites sensitive fields in responses in memory. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Why did my query fail when the account has dataset read access?

Reading data and running a query require two separate permissions in Google Cloud. Your identity needs a data viewer role on the dataset and a job user role on the project.

Should engineers share one service account key for local testing?

No, sharing static key files makes it impossible to track who ran a specific query. If a laptop is lost, you must rotate the key and break every local setup.

How can I avoid downloading JSON key files for external apps?

You can set up workload identity federation to link your external platform with Google Cloud. This lets external workloads trade their native identity for short-lived cloud tokens without stored keys.

The query runs. The emails stay hidden.