embulk/embulk-output-bigquery

Supporting JSON authentication keys

frsyuki opened this issue · 2 comments

#13 added support for LocalFile class. This allows us to embed authentication information in config file. For example,

out:
  type: bigquery
  auth_method: private_key
  project: my-proj-1234
  dataset: ds1
  table: ts4
  auto_create_table: true
  schema_file:
    content: |
      {
         ..
      }
  p12_keyfile:
    base64: |
      aG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhv
      Z2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dl
      CmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpo
      b2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9n
      ZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UK
      aG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhv
      Z2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dl
      CmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpo
      b2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQpob2dlCmhvZ2UKaG9nZQo=
...

This is good for us to deploy to servers because we can bundle all configuration in one file.

However, creating base64 of .p12 file needs additional work. It would be useful if it supports JSON authentication files. For example,

out:
  type: bigquery
  auth_method: json_key
  json_keyfile: /path/to/auth.json

or

out:
  type: bigquery
  auth_method: json_key
  json_keyfile:
    content: |
      {
          "private_key_id": "123456789",
          "private_key": "-----BEGIN PRIVATE KEY-----\nABCDEF",
          "client_email": "..."
       }
...

@frsyuki I implemented this auth_method at #17.
Do you have any advise or order about this pull-request?

If no, I'll merge it and release new version.

I implemented at #17 and merged.