change some code to let ruby 2.1.2 can use no problem

This commit is contained in:
chiu 2021-01-23 21:10:41 +08:00
parent cd9b0126d3
commit c48221bcd9
4 changed files with 10 additions and 10 deletions

View File

@ -25,14 +25,14 @@ Gem::Specification.new do |gem|
end end
gem.require_paths = ["lib"] gem.require_paths = ["lib"]
gem.platform = Gem::Platform::RUBY 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 "jwt", ">= 1.4", "< 3.0"
gem.add_dependency "memoist", "~> 0.16" gem.add_dependency "memoist", "~> 0.16"
gem.add_dependency "multi_json", "~> 1.11" gem.add_dependency "multi_json", "~> 1.11"
gem.add_dependency "os", ">= 0.9", "< 2.0" 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" gem.add_development_dependency "yard", "~> 0.9"
end end

View File

@ -34,11 +34,11 @@ module Google
# Module Auth provides classes that provide Google-specific authorization # Module Auth provides classes that provide Google-specific authorization
# used to access Google APIs. # used to access Google APIs.
module Auth module Auth
NOT_FOUND_ERROR = <<~ERROR_MESSAGE.freeze NOT_FOUND_ERROR = """~ERROR_MESSAGE.freeze
Could not load the default credentials. Browse to Could not load the default credentials. Browse to
https://developers.google.com/accounts/docs/application-default-credentials https://developers.google.com/accounts/docs/application-default-credentials
for more information for more information
ERROR_MESSAGE ERROR_MESSAGE"""
module_function module_function

View File

@ -35,16 +35,16 @@ module Google
# Module Auth provides classes that provide Google-specific authorization # Module Auth provides classes that provide Google-specific authorization
# used to access Google APIs. # used to access Google APIs.
module Auth module Auth
NO_METADATA_SERVER_ERROR = <<~ERROR.freeze NO_METADATA_SERVER_ERROR = """
Error code 404 trying to get security access token Error code 404 trying to get security access token
from Compute Engine metadata for the default service account. This from Compute Engine metadata for the default service account. This
may be because the virtual machine instance does not have permission may be because the virtual machine instance does not have permission
scopes specified. scopes specified.
ERROR """
UNEXPECTED_ERROR_SUFFIX = <<~ERROR.freeze UNEXPECTED_ERROR_SUFFIX = """
trying to get security access token from Compute Engine metadata for trying to get security access token from Compute Engine metadata for
the default service account the default service account
ERROR """
# Extends Signet::OAuth2::Client so that the auth token is obtained from # Extends Signet::OAuth2::Client so that the auth token is obtained from
# the GCE metadata server. # the GCE metadata server.

View File

@ -48,7 +48,7 @@ module Signet
def apply! a_hash, opts = {} def apply! a_hash, opts = {}
# fetch the access token there is currently not one, or if the client # fetch the access token there is currently not one, or if the client
# has expired # 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) fetch_access_token! opts if send(token_type).nil? || expires_within?(60)
a_hash[AUTH_METADATA_KEY] = "Bearer #{send token_type}" a_hash[AUTH_METADATA_KEY] = "Bearer #{send token_type}"
end end