Class: Embulk::Output::Bigquery::Auth
- Inherits:
-
Object
- Object
- Embulk::Output::Bigquery::Auth
- Defined in:
- lib/embulk/output/bigquery/auth.rb
Instance Attribute Summary collapse
-
#auth_method ⇒ Object
readonly
Returns the value of attribute auth_method.
-
#json_key ⇒ Object
readonly
Returns the value of attribute json_key.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #authenticate ⇒ Object
-
#initialize(task, scope) ⇒ Auth
constructor
A new instance of Auth.
Constructor Details
#initialize(task, scope) ⇒ Auth
Returns a new instance of Auth.
10 11 12 13 14 |
# File 'lib/embulk/output/bigquery/auth.rb', line 10 def initialize(task, scope) @auth_method = task['auth_method'] @json_key = task['json_keyfile'] @scope = scope end |
Instance Attribute Details
#auth_method ⇒ Object (readonly)
Returns the value of attribute auth_method.
8 9 10 |
# File 'lib/embulk/output/bigquery/auth.rb', line 8 def auth_method @auth_method end |
#json_key ⇒ Object (readonly)
Returns the value of attribute json_key.
8 9 10 |
# File 'lib/embulk/output/bigquery/auth.rb', line 8 def json_key @json_key end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
8 9 10 |
# File 'lib/embulk/output/bigquery/auth.rb', line 8 def scope @scope end |
Instance Method Details
#authenticate ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/embulk/output/bigquery/auth.rb', line 16 def authenticate case auth_method when 'authorized_user' key = StringIO.new(json_key) return Google::Auth::UserRefreshCredentials.make_creds(json_key_io: key, scope: scope) when 'compute_engine' return Google::Auth::GCECredentials.new when 'service_account', 'json_key' # json_key is for backward compatibility key = StringIO.new(json_key) return Google::Auth::ServiceAccountCredentials.make_creds(json_key_io: key, scope: scope) when 'application_default' return Google::Auth.get_application_default([scope]) else raise ConfigError.new("Unknown auth method: #{auth_method}") end end |