Login to bigquery from golang using json keyfile

Viewed 2125

So I have a json keyfile that looks like this:

{
  "user_agent": null,
  "_scopes": "https://www.googleapis.com/auth/bigquery",
  "token_uri": "https://www.googleapis.com/oauth2/v4/token",
  "refresh_token": null,
  "_service_account_email": "...",
  "assertion_type": null,
  "_kwargs": {},
  "revoke_uri": "https://accounts.google.com/o/oauth2/revoke",
  "_private_key_pkcs8_pem": "-----BEGIN PRIVATE KEY----- ..."
  ...
}

I want to login using this file to bigquery, with Golang. I looked through the examples at https://github.com/GoogleCloudPlatform/google-cloud-go but couldn't find anything related there how to create a new bigquery client using the keyfile. Am I missing something obvious?

In python the quivalent is:

        credentials = ServiceAccountCredentials.from_json_keyfile_name(
                'keyfile.json',
                'https://www.googleapis.com/auth/bigquery')

        ...
1 Answers
Related