fix: Use apply_request_options for batch auth header

Use HttpCommand#apply_request_options to add the Authorization header
for individual batch requests, as it supports both OAuth token strings and
googleauth/signet objects.

[pr #823, refs #822, closes #817]
This commit is contained in:
Mike Moore authored and GitHub committed 2019-08-19 15:16:51 -06:00
1 parent 837cf00706
commit 33a4aea60d
2 files changed
+55 -2

No files matched your search

+2 -2
View File
@@ -163,6 +163,8 @@ module Google
# the serialized request
def to_part(call)
call.prepare!
# This will add the Authorization header if needed.
call.apply_request_options(call.header)
parts = []
parts << build_head(call)
parts << build_body(call) unless call.body.nil?
@@ -177,8 +179,6 @@ module Google
call.header.each do |key, value|
request_head << sprintf("\r\n%s: %s", key, value)
end
token = call.options.authorization
request_head << "\r\nAuthorization: Bearer #{token}" unless token.nil?
request_head << sprintf("\r\nHost: %s", call.url.host)
request_head << "\r\n\r\n"
StringIO.new(request_head)