Http 500 Google Service Account Error - Python

I am pulling my hair out trying to figure this out, so I hope someone can help.

It seems like a relatively simple Google API endpoint access code with a service account, but I get Http Error 500

It works great with the Tasks API, same authentication.

My source code:

import httplib2 import pprint import sys from apiclient.discovery import build from oauth2client.client import SignedJwtAssertionCredentials f = file('key.p12', 'rb') key = f.read() f.close() credentials = SignedJwtAssertionCredentials( ' 403695561042-6ntna04usrl5sscg3ovij6t4d8vfvsqp@developer.gservice account.com', key, scope='https://www.googleapis.com/auth/apps.order.readonly') http = httplib2.Http() http = credentials.authorize(http) service = build("reseller", "v1", http=http) lists = service.subscriptions().list().execute(http=http) print lists 

Answer:

 HttpError: <unprintable HttpError object> 

Traceback:

 Traceback (most recent call last): File "/Library/Python/2.7/site-packages/flask/app.py", line 1701, in __call__ return self.wsgi_app(environ, start_response) File "/Library/Python/2.7/site-packages/flask/app.py", line 1689, in wsgi_app response = self.make_response(self.handle_exception(e)) File "/Library/Python/2.7/site-packages/flask/app.py", line 1687, in wsgi_app response = self.full_dispatch_request() File "/Library/Python/2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request rv = self.handle_user_exception(e) File "/Library/Python/2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request rv = self.dispatch_request() File "/Library/Python/2.7/site-packages/flask/app.py", line 1344, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/admin/Sites/newmind/reseller-api/app.py", line 79, in index lists = service.subscriptions().list().execute(http=http) File "build/bdist.macosx-10.8-intel/egg/oauth2client/util.py", line 120, in positional_wrapper return wrapped(*args, **kwargs) File "build/bdist.macosx-10.8-intel/egg/apiclient/http.py", line 678, in execute raise HttpError(resp, content, uri=self.uri) 

I copied the code directly from Google Sample, just changed the service name and authentication. http://code.google.com/p/google-api-python-client/source/browse/samples/service_account/tasks.py The task API returns http 200 with the same credentials.

When I use the pretty standard httplib2 request, here is the answer I get:

 WARNING:oauth2client.util:new_request() takes at most 1 positional argument (2 given) {'status': '500', 'content-length': '52', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'expires': 'Sat, 20 Oct 2012 06:25:19 GMT', 'server': 'GSE', '-content-encoding': 'gzip', 'cache-control': 'private, max-age=0', 'date': 'Sat, 20 Oct 2012 06:25:19 GMT', 'x-frame-options': 'SAMEORIGIN', 'content-type': 'application/json; charset=UTF-8'} { "error": { "code": 500, "message": null } } 

If anyone could help, I would be very grateful.

thanks

+1
source share
2 answers

Most likely a long shot, but did you enable the reseller API in your project console? I remember that I had a similar problem when trying to access a service other than the one I originally used.

Change In the comments below, an alternative solution was to use the stream and set access_type offline to allow the token to be updated without requiring re-authentication of the user.

+2
source

Without using a stream, you can do the following:

The error you are getting is due to the fact that you authenticated the API correctly, but b) the user you are using does not have access to the account you are trying to access.

I had the same problem, it was solved by adding the email address of the OAuth2 service account for users of the Google Analytics account.

For each account that you want to access, you will have to add this separately.

0
source

All Articles