diff --git a/generate/libraries/gcp_backend.rb b/generate/libraries/gcp_backend.rb index cf181b149..4ae6316ba 100644 --- a/generate/libraries/gcp_backend.rb +++ b/generate/libraries/gcp_backend.rb @@ -191,7 +191,7 @@ def camel_case(data) class GcpApiConnection def initialize - @service_account_file = ENV['GOOGLE_APPLICATION_CREDENTIALS'] + @google_application_credentials = ENV['GOOGLE_APPLICATION_CREDENTIALS'] end def fetch_auth @@ -200,8 +200,8 @@ def fetch_auth [ 'https://www.googleapis.com/auth/cloud-platform', ], - ).from_service_account_json!( - @service_account_file, + ).from_google_credentials_json!( + @google_application_credentials, ) end Network::Authorization.new.from_application_default! @@ -362,10 +362,10 @@ def for!(*scopes) self end - def from_service_account_json!(service_account_file) + def from_google_credentials_json!(credentials_file) raise 'Missing argument for scopes' if @scopes.empty? - @authorization = ::Google::Auth::ServiceAccountCredentials.make_creds( - json_key_io: File.open(service_account_file), + @authorization = ::Google::Auth::DefaultCredentials.make_creds( + json_key_io: File.open(credentials_file), scope: @scopes, ) self diff --git a/libraries/gcp_backend.rb b/libraries/gcp_backend.rb index 28e4afa5c..afc2be770 100644 --- a/libraries/gcp_backend.rb +++ b/libraries/gcp_backend.rb @@ -197,17 +197,17 @@ class GcpApiConnection def initialize config_name = Inspec::Config.cached.unpack_train_credentials[:host] ENV['CLOUDSDK_ACTIVE_CONFIG_NAME'] = config_name - @service_account_file = config_name.blank? && ENV['GOOGLE_APPLICATION_CREDENTIALS'] + @google_application_credentials = config_name.blank? && ENV['GOOGLE_APPLICATION_CREDENTIALS'] end def fetch_auth - unless @service_account_file.nil? + unless @google_application_credentials.nil? return Network::Authorization.new.for!( [ 'https://www.googleapis.com/auth/cloud-platform', ], - ).from_service_account_json!( - @service_account_file, + ).from_google_credentials_json!( + @google_application_credentials, ) end Network::Authorization.new.from_application_default! @@ -387,10 +387,10 @@ def for!(*scopes) self end - def from_service_account_json!(service_account_file) + def from_google_credentials_json!(credentials_file) raise 'Missing argument for scopes' if @scopes.empty? - @authorization = ::Google::Auth::ServiceAccountCredentials.make_creds( - json_key_io: File.open(service_account_file), + @authorization = ::Google::Auth::DefaultCredentials.make_creds( + json_key_io: File.open(credentials_file), scope: @scopes, ) self