fix: Pass scope through when getting metadata-based access tokens

This commit is contained in:
Hayden Ball authored and GitHub committed 2020-07-08 08:13:38 -07:00
1 parent dcdf7cddbf
commit 48c689aa93
4 files changed
+21 -3

No files matched your search

+1 -1
View File
@@ -75,7 +75,7 @@ module Google
GCECredentials.unmemoize_all
raise NOT_FOUND_ERROR
end
GCECredentials.new
GCECredentials.new scope: scope
end
end
end
+2 -1
View File
@@ -85,7 +85,8 @@ module Google
c = options[:connection] || Faraday.default_connection
retry_with_error do
uri = target_audience ? COMPUTE_ID_TOKEN_URI : COMPUTE_AUTH_TOKEN_URI
query = target_audience ? { "audience" => target_audience, "format" => "full" } : nil
query = target_audience ? { "audience" => target_audience, "format" => "full" } : {}
query[:scopes] = Array(scope).join " " if scope
headers = { "Metadata-Flavor" => "Google" }
resp = c.get uri, query, headers
case resp.status