Skip to content

Commit 9e9165e

Browse files
authored
Merge pull request #107 from embulk/authorized_user
Cleanup auth_method
2 parents a75a349 + 6eceb56 commit 9e9165e

36 files changed

+175
-87
lines changed

README.md

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ OAuth flow for installed applications.
2929

3030
| name | type | required? | default | description |
3131
|:-------------------------------------|:------------|:-----------|:-------------------------|:-----------------------|
32-
| mode | string | optional | "append" | See [Mode](#mode) |
33-
| auth_method | string | optional | "json\_key" | `json_key`, `compute_engine`, or `application_default`
34-
| json_keyfile | string | required when auth_method is json_key | | Fullpath of json key |
35-
| project | string | required if json_keyfile is not given | | project_id |
32+
| mode | string | optional | "append" | See [Mode](#mode) |
33+
| auth_method | string | optional | "application\_default" | See [Authentication](#authentication) |
34+
| json_keyfile | string | optional | | keyfile path or `content` |
35+
| project | string | required unless service\_account's `json_keyfile` is given. | | project\_id |
3636
| dataset | string | required | | dataset |
3737
| location | string | optional | nil | geographic location of dataset. See [Location](#location) |
3838
| table | string | required | | table name, or table name with a partition decorator such as `table_name$20160929`|
@@ -106,7 +106,7 @@ Following options are same as [bq command-line tools](https://cloud.google.com/b
106106
out:
107107
type: bigquery
108108
mode: append
109-
auth_method: json_key # default
109+
auth_method: service_account
110110
json_keyfile: /path/to/json_keyfile.json
111111
project: your-project-000
112112
dataset: your_dataset_name
@@ -115,15 +115,15 @@ out:
115115
source_format: NEWLINE_DELIMITED_JSON
116116
```
117117
118-
### location
118+
### Location
119119
120120
The geographic location of the dataset. Required except for US and EU.
121121
122122
GCS bucket should be in same region when you use `gcs_bucket`.
123123

124124
See also [Dataset Locations | BigQuery | Google Cloud](https://cloud.google.com/bigquery/docs/dataset-locations)
125125

126-
### mode
126+
### Mode
127127

128128
5 modes are provided.
129129

@@ -162,40 +162,69 @@ NOTE: BigQuery does not support replacing (actually, copying into) a non-partiti
162162

163163
### Authentication
164164

165-
There are three methods supported to fetch access token for the service account.
165+
There are four authentication methods
166166

167-
1. JSON key of GCP(Google Cloud Platform)'s service account
168-
1. Pre-defined access token (Google Compute Engine only)
169-
1. [Application Default](https://cloud.google.com/docs/authentication/production)
167+
1. `service_account` (or `json_key` for backward compatibility)
168+
1. `authorized_user`
169+
1. `compute_engine`
170+
1. `application_default`
170171

171-
#### JSON key of GCP's service account
172+
#### service\_account (or json\_key)
172173

173-
You first need to create a service account (client ID),
174-
download its json key and deploy the key with embulk.
174+
Use GCP service account credentials.
175+
You first need to create a service account, download its json key and deploy the key with embulk.
175176

176177
```yaml
177178
out:
178179
type: bigquery
179-
auth_method: json_key
180+
auth_method: service_account
180181
json_keyfile: /path/to/json_keyfile.json
181182
```
182183

183-
You can also embed contents of json_keyfile at config.yml.
184+
You can also embed contents of `json_keyfile` at config.yml.
184185

185186
```yaml
186187
out:
187188
type: bigquery
188-
auth_method: json_key
189+
auth_method: service_account
189190
json_keyfile:
190191
content: |
191192
{
192193
"private_key_id": "123456789",
193194
"private_key": "-----BEGIN PRIVATE KEY-----\nABCDEF",
194195
"client_email": "..."
195-
}
196+
}
196197
```
197198

198-
#### Pre-defined access token (GCE only)
199+
#### authorized\_user
200+
201+
Use Google user credentials.
202+
You can get your credentials at `~/.config/gcloud/application_default_credentials.json` by running `gcloud auth login`.
203+
204+
```yaml
205+
out:
206+
type: bigquery
207+
auth_method: authorized_user
208+
json_keyfile: /path/to/credentials.json
209+
```
210+
211+
You can also embed contents of `json_keyfile` at config.yml.
212+
213+
```yaml
214+
out:
215+
type: bigquery
216+
auth_method: service_account
217+
json_keyfile:
218+
content: |
219+
{
220+
"client_id":"xxxxxxxxxxx.apps.googleusercontent.com",
221+
"client_secret":"xxxxxxxxxxx",
222+
"refresh_token":"xxxxxxxxxxx",
223+
"type":"authorized_user"
224+
}
225+
```
226+
227+
#### compute\_engine
199228

200229
On the other hand, you don't need to explicitly create a service account for embulk when you
201230
run embulk in Google Compute Engine. In this third authentication method, you need to
@@ -208,9 +237,10 @@ out:
208237
auth_method: compute_engine
209238
```
210239

211-
#### Application Default
240+
#### application\_default
212241

213-
See https://cloud.google.com/docs/authentication/production
242+
Use Application Default Credentials (ADC).
243+
See https://cloud.google.com/docs/authentication/production for details.
214244

215245
```yaml
216246
out:

example/config_append_direct_schema_update_options.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in:
1919
out:
2020
type: bigquery
2121
mode: append_direct
22-
auth_method: json_key
22+
auth_method: service_account
2323
json_keyfile: example/your-project-000.json
2424
dataset: your_dataset_name
2525
table: your_table_name

example/config_client_options.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in:
1919
out:
2020
type: bigquery
2121
mode: replace
22-
auth_method: json_key
22+
auth_method: service_account
2323
json_keyfile: example/your-project-000.json
2424
dataset: your_dataset_name
2525
table: your_table_name

example/config_csv.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in:
1919
out:
2020
type: bigquery
2121
mode: replace
22-
auth_method: json_key
22+
auth_method: service_account
2323
json_keyfile: example/your-project-000.json
2424
dataset: your_dataset_name
2525
table: your_table_name

example/config_delete_in_advance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in:
1919
out:
2020
type: bigquery
2121
mode: delete_in_advance
22-
auth_method: json_key
22+
auth_method: service_account
2323
json_keyfile: example/your-project-000.json
2424
dataset: your_dataset_name
2525
table: your_table_name

example/config_delete_in_advance_field_partitioned_table.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in:
1919
out:
2020
type: bigquery
2121
mode: delete_in_advance
22-
auth_method: json_key
22+
auth_method: service_account
2323
json_keyfile: example/your-project-000.json
2424
dataset: your_dataset_name
2525
table: your_field_partitioned_table_name

example/config_delete_in_advance_partitioned_table.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in:
1919
out:
2020
type: bigquery
2121
mode: delete_in_advance
22-
auth_method: json_key
22+
auth_method: service_account
2323
json_keyfile: example/your-project-000.json
2424
dataset: your_dataset_name
2525
table: your_partitioned_table_name$20160929

example/config_expose_errors.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in:
1919
out:
2020
type: bigquery
2121
mode: replace
22-
auth_method: json_key
22+
auth_method: service_account
2323
json_keyfile: example/your-project-000.json
2424
dataset: your_dataset_name
2525
table: your_table_name

example/config_gcs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in:
1919
out:
2020
type: bigquery
2121
mode: replace
22-
auth_method: json_key
22+
auth_method: service_account
2323
json_keyfile: example/your-project-000.json
2424
dataset: your_dataset_name
2525
table: your_table_name

example/config_guess_from_embulk_schema.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ in:
1919
out:
2020
type: bigquery
2121
mode: replace
22-
auth_method: json_key
22+
auth_method: service_account
2323
json_keyfile: example/your-project-000.json
2424
dataset: your_dataset_name
2525
table: your_table_name

0 commit comments

Comments
 (0)