Area: Ingestion Issues
Sub-Area: CLI Authentication / datahub-rest Sink Configuration
Applies to: Cloud instances that use the DataHub Cloud API gateway
Issue
You run datahub ingest from outside DataHub (for example a Kubernetes job or a CI script) with a datahub-rest sink that points at your DataHub Cloud instance. The run stops before it ingests anything, with an authentication error from the /config check that the sink runs at startup.
Error Messages
The sink reports the failure in two lines:
Failed to connect to DataHub with DataHubRestEmitter: configured to talk to https://<your-instance>.acryl.io/gms with token: abcd**********wxyz
Unable to connect to https://<your-instance>.acryl.io/gms/config - got an authentication error: <server response>.
You Might Be Asking
- Why does the same recipe work from the Ingestion page in the UI but fail from my cluster or script?
- Why do I get a 401 with a token I just created?
- Does my account need more privileges to fix this?
- How do I test the token and server URL without running the full pipeline?
Cause
At startup the datahub-rest sink sends GET <server>/config with your token. The CLI prints got an authentication error only when that request comes back with HTTP 401.
DataHub itself serves /config without authentication. The 401 comes from the DataHub Cloud API gateway, which sits in front of DataHub. The gateway returns a 401 when the request has no bearer token. The most common reason is that the sink sent no token. The recipe has no token, the key is misspelled, or the value is empty.
Privileges and roles do not cause this error. The check confirms who you are, not what you can do.
Some newer Cloud instances do not use the gateway. On these instances the startup check does not return this 401. A bad token fails later, on a request that needs authentication.
When you run a recipe from the Ingestion page, the DataHub executor supplies the credentials. When you run datahub ingest yourself, the datahub-rest sink sends the token from its config block. It does not read DATAHUB_GMS_TOKEN.
Solution
-
Read the token hint in the error. The first error line shows the first 4 and last 4 characters of the token the sink sent (
with token: abcd**********wxyz). Compare them with the token you meant to use. If the line ends after the server URL with nowith token:part, the sink sent no token at all. -
Check the sink block in the recipe. Put
serverandtokenundersink.config:sink: type: datahub-rest config: server: "https://<your-instance>.acryl.io/gms" token: "<your-access-token>"Use a space after each colon and keep indentation consistent. Spell the key exactly
token. The sink ignores keys it doesn't know, so a misspelled key gives no error and sends no token. See the DataHub REST sink docs. -
Check the token variable if you inject it. Recipes expand
${VAR}from the environment:sink: type: datahub-rest config: server: "https://<your-instance>.acryl.io/gms" token: "${DATAHUB_TOKEN}"If
DATAHUB_TOKENis not set at all, the recipe fails to load with an unbound variable error before it contacts DataHub. If it is set but empty, the sink sends no token and you get the 401. Check the variable inside the pod or job before ingestion starts:#!/bin/bash if [ -z "$DATAHUB_TOKEN" ]; then echo "ERROR: DATAHUB_TOKEN is not set or is empty." exit 1 fi echo "DATAHUB_TOKEN length: ${#DATAHUB_TOKEN}" datahub ingest -c /path/to/recipe.yml -
Generate a new token if you have no token to use.
- Log in to the DataHub Cloud UI of the instance in your
serverURL. - Go to Settings > Access Tokens.
- Click Generate new token.
- Pick a value in Expires in. Never is offered only if your instance allows tokens without expiry.
- Copy the token right away. DataHub shows it only once.
- Update your recipe or secret store with the new value.
- Log in to the DataHub Cloud UI of the instance in your
-
Test the URL on its own.
datahub check server-configruns the same/configcheck. It has no--serveror--tokenoptions. It reads the connection fromDATAHUB_GMS_URLandDATAHUB_GMS_TOKEN, or from~/.datahubenvif those are not set. See the DataHub CLI docs.export DATAHUB_GMS_URL="https://<your-instance>.acryl.io/gms" export DATAHUB_GMS_TOKEN="<your-access-token>" datahub check server-configIf it prints the server configuration, the URL reaches your instance. This check does not prove the token is valid. If it fails with the same authentication error, check that
DATAHUB_GMS_TOKENis set and not empty.