Skip to content

Commit

Permalink
Merge pull request #56 from vsubramani/master
Browse files Browse the repository at this point in the history
Fix for ADC not working on some windows machines
  • Loading branch information
tbetbetbe committed Jan 4, 2016
2 parents c75d739 + 0be20dd commit 642a70f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions googleauth.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ Gem::Specification.new do |s|
s.add_dependency 'jwt', '~> 1.4'
s.add_dependency 'memoist', '~> 0.12'
s.add_dependency 'multi_json', '~> 1.11'
s.add_dependency 'os', '~> 0.9'
s.add_dependency 'signet', '~> 0.7'
end
13 changes: 4 additions & 9 deletions lib/googleauth/credentials_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

require 'memoist'
require 'os'
require 'rbconfig'

module Google
Expand Down Expand Up @@ -55,12 +56,6 @@ module CredentialsLoader

SYSTEM_DEFAULT_ERROR = 'Unable to read the system default credential file'

# determines if the current OS is windows
def windows?
RbConfig::CONFIG['host_os'] =~ /Windows|mswin/
end
memoize :windows?

# make_creds proxies the construction of a credentials instance
#
# By default, it calls #new on the current class, but this behaviour can
Expand Down Expand Up @@ -91,10 +86,10 @@ def from_env(scope = nil)
#
# @param scope [string|array|nil] the scope(s) to access
def from_well_known_path(scope = nil)
home_var = windows? ? 'APPDATA' : 'HOME'
home_var = OS.windows? ? 'APPDATA' : 'HOME'
base = WELL_KNOWN_PATH
root = ENV[home_var].nil? ? '' : ENV[home_var]
base = File.join('.config', base) unless windows?
base = File.join('.config', base) unless OS.windows?
path = File.join(root, base)
return nil unless File.exist?(path)
File.open(path) do |f|
Expand All @@ -108,7 +103,7 @@ def from_well_known_path(scope = nil)
#
# @param scope [string|array|nil] the scope(s) to access
def from_system_default_path(scope = nil)
if windows?
if OS.windows?
return nil unless ENV['ProgramData']
prefix = File.join(ENV['ProgramData'], 'Google/Auth')
else
Expand Down

0 comments on commit 642a70f

Please sign in to comment.