Skip to content

Commit

Permalink
Only authenticate batch requests if the credentials are non-null.
Browse files Browse the repository at this point in the history
This should address googleapis#350.
  • Loading branch information
Matthew Lee Gilson committed Feb 15, 2017
1 parent dfc69e9 commit c5a7e5b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion googleapiclient/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,14 @@ def _serialize_request(self, request):

if request.http is not None and hasattr(request.http.request,
'credentials'):
request.http.request.credentials.apply(headers)
# It is possible to have credentials and still not have an access token.
# (e.g. with application default credentials). If that is the case, do
# not serialize the authentication headers with this request. Instead,
# assume that the batch has an authorization header which will trickle
# down to all of the individual requests.
if (getattr(request.http.request.credentials, 'access_token', None)
is not None):
request.http.request.credentials.apply(headers)

# MIMENonMultipart adds its own Content-Type header.
if 'content-type' in headers:
Expand Down

0 comments on commit c5a7e5b

Please sign in to comment.