Class: CloudSQLRubyConnector::Credentials::ServiceAccount
- Defined in:
- lib/cloud_sql_ruby_connector/credentials/service_account.rb
Overview
Service Account credentials from JSON key file
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#client_email ⇒ Object
readonly
Returns the value of attribute client_email.
Class Method Summary collapse
-
.from_file(path) ⇒ ServiceAccount, UserCredentials
Load credentials from a JSON file.
Instance Method Summary collapse
-
#initialize(data) ⇒ ServiceAccount
constructor
A new instance of ServiceAccount.
Methods inherited from Base
Constructor Details
#initialize(data) ⇒ ServiceAccount
Returns a new instance of ServiceAccount.
41 42 43 44 45 46 |
# File 'lib/cloud_sql_ruby_connector/credentials/service_account.rb', line 41 def initialize(data) super() validate_required_fields!(data) @client_email = data["client_email"] @private_key = OpenSSL::PKey::RSA.new(data["private_key"]) end |
Instance Attribute Details
#client_email ⇒ Object (readonly)
Returns the value of attribute client_email.
26 27 28 |
# File 'lib/cloud_sql_ruby_connector/credentials/service_account.rb', line 26 def client_email @client_email end |
Class Method Details
.from_file(path) ⇒ ServiceAccount, UserCredentials
Load credentials from a JSON file
31 32 33 34 35 36 37 38 39 |
# File 'lib/cloud_sql_ruby_connector/credentials/service_account.rb', line 31 def self.from_file(path) data = JSON.parse(File.read(path)) if data["type"] == "authorized_user" UserCredentials.new(data) else new(data) end end |