Reputation: 413
I want to give service account information outside to "bq" command as a parameter, in order to change its authentication flexibly. I passed some options to "bq" command like:
$ 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 in my local PC after configuring with gsutil with my account, but it seems that "bq" command doesn't accept any commands before configuring with "gcloud" or "gsutil" even if 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 purpose with "bq" or not? I've tried exporting GOOGLE_APPLICATION_CREDENTIALS environment but it doesn't seem to work.
Thank you in advance.
Upvotes: 3
Views: 2487
Reputation: 155
For authentication in "bq", there is "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 may be no recommended way for authentication solely from "bq" without using "gcloud".
Upvotes: 3