how to switch GCP authentication account for dbt-BigQuery runs

Viewed 655

I have two GCP accounts. they have different access permissions to different GCP BigQuery datasets, for which I need to run dbt in different scenarios.

Right now, I use oauth method in dbt_profile as below.

dbt_project:
  target: default
  outputs:
    default:
      type: bigquery
      method: oauth

When I do dbt run in CLI the first time, It will ask for gcp oauth login.

Now the question is, how do I switch my GCP accounts between runs of dbt run when I need to?

1 Answers

I found the dbt is using application-default in gcloud auth.

So the way to switch to a different GCP account is to do

gcloud auth application-default login

it prompts the browser to log in with another GCP account.

Related