How to set up shell command "bq" (bigquery) without gcloud or gsutil?

I want to provide the service account information outside of the "bq" command as a parameter to flexibly change its authentication. I passed some options to the "bq" command, for example:

$ bq load --service_account=<my_service_account>
          --service_account_credential_file=<credential_output>
          --service_account_private_key_file=<path_to_pem>
          --project_id=<my_project>
          <dataset>.<table> <localfile> <schema>

      

It works well on my local PC after configuring with gsutil with my account, but it seems that the "bq" command doesn't take any commands before configuring with "gcloud" or "gsutil" even though the service account information is given:

> You do not currently have an active account selected.
> Please run:
> 
> $ gcloud auth login
> 
> to obtain new credentials, or if you have already logged in with a different account:
>     
> $ gcloud config set account ACCOUNT
> 
> to select an already authenticated account to use.

      

Can I achieve this goal with "bq" or not? I tried to export the GOOGLE_APPLICATION_CREDENTIALS environment, but it doesn't work.

Thanks in advance.

+3


source to share


1 answer


For authentication, "bq" has an "init" command. But even if you run:

bq init

      

The system returns the following warning:



The "init" command is no longer needed with the Cloud SDK.
To authenticate, run gcloud auth.

      

So, it seems that there can be no recommended way to authenticate exclusively from "bq" without using "gcloud".

+2


source







All Articles