tush1r / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

Exceptions with build() function gets NoneType #279

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
oauth2client issue, cannot build service object.

Trying to login using service account to access api(Drive, Analytics) and there 
is a new exception raised as mentioned below.

We have the same code on production working for a long while. 
We are facing this issues from last week, this is too 100% produceble, but 
happnes very often.

Code we execute :

SERVICE_ACCOUNT= '.pem key path'

key = open(os.path.join(os.path.dirname(__file__), KEY)).read()
credentials = PyCryptoSignedJwtAssertionCredentials(SERVICE_ACCOUNT,key,scope=" 
".join(appsConfig[service]['SCOPES']))
http = httplib2.Http(memcache)
httplib2.debuglevel = True
http = credentials.authorize(http)
service = build(serviceName=service, version=version, http=http)

What we see: 

File "/base/data/home/apps/<app id>/<app 
ver>/googleAPIClientV3/locusClient.py", line 77, in getService
    service = build(serviceName=service, version=version, http=http)
  File "/base/data/home/apps/<app id>/<app ver>/oauth2client/util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/base/data/home/apps/<app id>/<app ver>/apiclient/discovery.py", line 193, in build
    resp, content = http.request(requested_url)
...............................
  File "/base/data/home/apps/<app id>/<app ver>/httplib2/__init__.py", line 1188, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/base/data/home/apps/<app id>/<app ver>/httplib2/__init__.py", line 1171, in _conn_request
    content = response.read()
AttributeError: 'NoneType' object has no attribute 'read'

Do any one has any recommendation for this. 

Original issue reported on code.google.com by sande...@g.advaiya.com on 11 Jun 2013 at 10:30

GoogleCodeExporter commented 9 years ago
To clarify, are you saying it happens very often, but not 100% of the time?

Original comment by dhermes@google.com on 11 Jun 2013 at 4:17

GoogleCodeExporter commented 9 years ago
We were facing it very often yesterday.. today it seems to be 100%.

... can this happen because of credit card issues at api console!!?

Original comment by sande...@g.advaiya.com on 11 Jun 2013 at 4:25

GoogleCodeExporter commented 9 years ago
I would recommend using apiclient.discovery.build_from_document() instead of 
apiclient.discovery.build() if you are having issues with network.

Original comment by dhermes@google.com on 11 Jun 2013 at 10:04

GoogleCodeExporter commented 9 years ago

Original comment by jcgregorio@google.com on 5 Aug 2013 at 1:55