Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BatchHttpRequest does not check for existence of an accesstoken before calling apply() #211

Closed
@elibixby

Description

@elibixby

@nathanielmanistaatgoogle @jonparrott

To repro:

from googleapiclient.discovery import build
from oauth2client.client import GoogleCredentials

def foo(b, a, r):
   pass

def main():
    api = build('servicemanagement', 'v1', credentials=GoogleCredentials.from_stream('static/service_account.json'))
    batch = api.new_batch_http_request(callback=foo)
    batch.add(api.services().list())
    batch.execute()

You will get something like

File "/usr/local/google/home/elibixby/gobrepos/devrel/apps/cloud/free-trial-tour/project_utils/apis.py", line 45, in enable_async
batch.execute()
File "/usr/local/google/home/elibixby/envs/iliad/local/lib/python2.7/site-packages/oauth2client/util.py", line 137, in positional_wrapper
return wrapped(_args, *_kwargs)
File "/usr/local/google/home/elibixby/envs/iliad/local/lib/python2.7/site-packages/googleapiclient/http.py", line 1325, in execute
self._execute(http, self._order, self._requests)
File "/usr/local/google/home/elibixby/envs/iliad/local/lib/python2.7/site-packages/googleapiclient/http.py", line 1249, in _execute
body = self._serialize_request(request)
File "/usr/local/google/home/elibixby/envs/iliad/local/lib/python2.7/site-packages/googleapiclient/http.py", line 1120, in _serialize_request
request.http.request.credentials.apply(headers)
File "/usr/local/google/home/elibixby/envs/iliad/local/lib/python2.7/site-packages/oauth2client/client.py", line 676, in apply
headers['Authorization'] = 'Bearer ' + self.access_token
TypeError: cannot concatenate 'str' and 'NoneType' objects

FYI my pip freeze is:

Flask==0.10.1
Flask-SeaSurf==0.2.2
Jinja2==2.8
MarkupSafe==0.23
Werkzeug==0.11.5
argparse==1.2.1
google-api-python-client==1.5.0
httplib2==0.9.2
itsdangerous==0.24
oauth2client==2.0.1
pyasn1==0.1.9
pyasn1-modules==0.0.8
requirements-dev.txt==0.0.0
rsa==3.4.2
simplejson==3.8.2
six==1.10.0
talisman==0.1.0
uritemplate==0.6
wsgiref==0.1.2

Metadata

Metadata

Labels

🚨This issue needs some love.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions