Set up a service account for pipelines
Create a service account for a pipeline, give it data access, and register it in Airflow as the lakehouse connection.
A pipeline that touches the lakehouse works as a service account, not as you. You create the
service account in the portal’s Identity app, give it data access in the Data Catalog, and
register it in Airflow as the databaas_lakehouse connection. databaas-utils reads that
connection, so no DAG ever holds a credential.
This page is the whole flow, once, for one pipeline. Every step happens in a browser.
Before you start
Prerequisite
- The Administer platform app permission. It shows Identity in the portal sidebar’s Administration group, and opens Admin → Connections in Airflow. See the permissions reference.
- An account in Identity that may create service users and their keys.
- The right to grant on the warehouse or namespace the pipeline will use: Manage grants or ownership on it, or Data admin. See data permissions.
<your-databaas-domain> below is the domain you open the portal on. Identity and the catalog sit on
its auth. and catalog. subdomains; step 3 needs both addresses.
1. Create the service account in Identity
- In the portal sidebar, open Identity under Administration.
- Users → Service Users → New. Name it after the pipeline it will run, for example
airflow-open-meteo. Access Token Type JWT. Save. - Open the new user → Keys → New → type JSON → pick an expiry → Add.
- The browser downloads a file once. There is no way to retrieve it again. If you lose it, delete the key and make a new one. You paste its contents into Airflow in step 3.
It looks like this:
{
"type": "serviceaccount",
"keyId": "391305913807408172",
"key": "-----BEGIN RSA PRIVATE KEY-----\n…\n-----END RSA PRIVATE KEY-----\n",
"userId": "391305903103544364"
}Do not use a Personal Access Token. Identity offers one on the same screen, and it looks like
the simpler option. It only works against Identity’s own APIs: the catalog cannot validate it and
rejects it with AuthenticationFailed. Use the JSON key. databaas-utils signs a short-lived
assertion with its private key and exchanges that for an access token each time a task needs one.
Copy the project ID
While you are in Identity, open Projects → Databaas and copy the project’s ID. Step 3 puts it in the connection’s scope: every token the pipeline gets must carry this project as its audience, or the catalog and Trino reject it.
2. Give it data access in the Data Catalog
The service account can authenticate, but it cannot see a single table until you grant it something.
- In the portal, open Data Catalog and select the namespace the pipeline owns, or the
databaas-lakehousewarehouse. - Open the Permissions tab and add a grant. Search for the name you gave the account in step 1; it is listed as a Service account.
- Grant what the pipeline needs: Select to read, Modify to write, and Create if it creates tables.
- Save.
Grant on the pipeline’s own namespace rather than the whole warehouse. A pipeline that can only write its own namespace cannot overwrite another team’s tables.
If the pipeline creates its own namespaces, which scoped() makes it do on every branch deploy, it
needs Create one level up, on the warehouse, not only inside a namespace that does not exist
yet.
See data permissions for every grant level.
3. Add the Airflow connection
This is what the DAG actually reads.
- In Pipelines, open Admin → Connections and add a new connection.
- Set Connection Type to Databaas Lakehouse first. The form then shows the lakehouse fields below.
- Fill in the fields in the table. Leave every other field empty; Description is optional free text.
- Save.
| Field | Value | Notes |
|---|---|---|
| Connection ID | databaas_lakehouse | The id databaas-utils uses unless a DAG passes another conn_id=. |
| Connection Type | Databaas Lakehouse | Gives the labelled form below instead of a JSON blob. |
| Lakekeeper URL | https://catalog.<your-databaas-domain> | The full address, including https://. Not the /catalog path: a URL ending in /catalog is rejected. |
| Warehouse | databaas-lakehouse, or empty | Empty means databaas-lakehouse. Set it if you granted on another warehouse in step 2. |
| Service account JSON key | the whole downloaded file | Open the file from step 1 in a text editor, select everything from the first { to the last }, and paste it unchanged. |
| Token URL | https://auth.<your-databaas-domain>/oauth/v2/token | Identity’s token endpoint. It must be the full URL, including https:// and /oauth/v2/token. |
| OAuth scope | openid urn:zitadel:iam:org:project:id:<project ID>:aud | Replace <project ID> with the ID from step 1. This puts the project in the token’s audience. |
Keep the trailing :aud
A scope without the trailing :aud gives a token the catalog accepts but Trino does not. Catalog
reads and writes then work, while anything that queries through Trino, such as a dbt run, fails with
401 Invalid Audience.
Check the Token URL character by character
Airflow does not check the fields when you save. A typo in Token URL, such as a missing /
before oauth, only shows up when the first task asks for a token, as a low-level connection
error. Verify the connection (below) before you run a real DAG.
Paste the key from the file, never retype it. A mangled newline inside the private key fails as an unrelated-looking signature error.
4. Use it in a DAG
Nothing to install and nothing to configure. Ask for what you need and the connection is resolved behind it.
from airflow.sdk import task
@task
def write_forecast(rows: list[dict]):
import pyarrow as pa
from databaas_utils.airflow import get_catalog, scoped
catalog = get_catalog()
table = catalog.load_table(f"{scoped('open_meteo')}.forecast")
table.append(pa.Table.from_pylist(rows, schema=table.schema().as_arrow()))Every helper — the catalog, file stores, Zarr groups, the index and scoped() — is listed in
what databaas-utils gives you. If you
registered the connection under another id, pass it as conn_id=. An unresolvable connection
raises ConnectionNotConfigured rather than quietly writing somewhere else.
Verifying
Airflow’s Test button for connections is turned off, so check the connection with a DAG. Add this one to your pipeline repository and trigger it once from the Airflow UI:
from airflow.sdk import dag, task
@dag(schedule=None, catchup=False)
def check_lakehouse_connection():
@task
def check():
from databaas_utils.airflow import LakehouseHook
ok, message = LakehouseHook().test_connection()
print(message)
if not ok:
raise RuntimeError(message)
check()
check_lakehouse_connection()The check fetches a token and reads the warehouse, and reports the first link in
the chain that broke: the connection fields, the token endpoint, or the warehouse. Success reads
Connected to … — warehouse 'databaas-lakehouse' resolved to ….
The check talks to the catalog only, so it does not catch a missing :aud in OAuth scope. If
your pipeline queries through Trino, confirm the scope against the table in step 3.
Troubleshooting
| Symptom | Cause |
|---|---|
AuthenticationFailed from the catalog | A Personal Access Token was used instead of the JSON key. See step 1. |
| A connection or URL error while fetching a token | Token URL has a typo or is not the full https://…/oauth/v2/token URL. See step 3. |
service_account_key was supplied without token_url | Token URL is empty. |
NoSuchWarehouse | The account has no grant on the warehouse, or Warehouse has a typo. See step 2. |
403 / not authorized on a namespace or table | The account has no grant. See step 2. |
403 only when creating a namespace | The grant is on the namespace, not the warehouse. See step 2. |
401 Invalid Audience from Trino | OAuth scope lacks the trailing :aud. See step 3. |
ConnectionNotConfigured | No connection under that id. Check the id the DAG asks for as well as the one you created. |
ConfigurationError: … has no host | Lakekeeper URL is empty. |
| Signature or token errors after editing the key | The private key’s newlines were mangled. Paste the file’s contents again. |
Notes
- One account per pipeline, not one per person. A pipeline authenticating as a person breaks when that person leaves, and its access is whatever that person happened to have rather than what the pipeline needs.
- Keys expire. You set the expiry yourself in step 1, so put it in a calendar. To rotate: create a new key, paste it into the connection’s Service account JSON key field, then delete the old key in Identity. Step 2 does not repeat, because the account itself does not change.