From c48221bcd9ac76e65e9044761f24a87c01510271 Mon Sep 17 00:00:00 2001 From: chiu Date: Sat, 23 Jan 2021 21:10:41 +0800 Subject: [PATCH] change some code to let ruby 2.1.2 can use no problem --- googleauth.gemspec | 6 +++--- lib/googleauth/application_default.rb | 4 ++-- lib/googleauth/compute_engine.rb | 8 ++++---- lib/googleauth/signet.rb | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/googleauth.gemspec b/googleauth.gemspec index 74fb9b6..89dcbfd 100755 --- a/googleauth.gemspec +++ b/googleauth.gemspec @@ -25,14 +25,14 @@ Gem::Specification.new do |gem| end gem.require_paths = ["lib"] gem.platform = Gem::Platform::RUBY - gem.required_ruby_version = ">= 2.4.0" + gem.required_ruby_version = ">= 2.0" - gem.add_dependency "faraday", ">= 0.17.3", "< 2.0" + gem.add_dependency "faraday", "~> 0.15.4" gem.add_dependency "jwt", ">= 1.4", "< 3.0" gem.add_dependency "memoist", "~> 0.16" gem.add_dependency "multi_json", "~> 1.11" gem.add_dependency "os", ">= 0.9", "< 2.0" - gem.add_dependency "signet", "~> 0.14" + gem.add_dependency "signet" gem.add_development_dependency "yard", "~> 0.9" end diff --git a/lib/googleauth/application_default.rb b/lib/googleauth/application_default.rb index ee21b76..cbfc32d 100644 --- a/lib/googleauth/application_default.rb +++ b/lib/googleauth/application_default.rb @@ -34,11 +34,11 @@ module Google # Module Auth provides classes that provide Google-specific authorization # used to access Google APIs. module Auth - NOT_FOUND_ERROR = <<~ERROR_MESSAGE.freeze + NOT_FOUND_ERROR = """~ERROR_MESSAGE.freeze Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information - ERROR_MESSAGE + ERROR_MESSAGE""" module_function diff --git a/lib/googleauth/compute_engine.rb b/lib/googleauth/compute_engine.rb index eb197df..cf6b529 100644 --- a/lib/googleauth/compute_engine.rb +++ b/lib/googleauth/compute_engine.rb @@ -35,16 +35,16 @@ module Google # Module Auth provides classes that provide Google-specific authorization # used to access Google APIs. module Auth - NO_METADATA_SERVER_ERROR = <<~ERROR.freeze + NO_METADATA_SERVER_ERROR = """ Error code 404 trying to get security access token from Compute Engine metadata for the default service account. This may be because the virtual machine instance does not have permission scopes specified. - ERROR - UNEXPECTED_ERROR_SUFFIX = <<~ERROR.freeze + """ + UNEXPECTED_ERROR_SUFFIX = """ trying to get security access token from Compute Engine metadata for the default service account - ERROR + """ # Extends Signet::OAuth2::Client so that the auth token is obtained from # the GCE metadata server. diff --git a/lib/googleauth/signet.rb b/lib/googleauth/signet.rb index d2b33ff..c3dba39 100644 --- a/lib/googleauth/signet.rb +++ b/lib/googleauth/signet.rb @@ -48,7 +48,7 @@ module Signet def apply! a_hash, opts = {} # fetch the access token there is currently not one, or if the client # has expired - token_type = target_audience ? :id_token : :access_token + token_type = defined?(target_audience) ? :id_token : :access_token fetch_access_token! opts if send(token_type).nil? || expires_within?(60) a_hash[AUTH_METADATA_KEY] = "Bearer #{send token_type}" end