Question

I went went trough the service accounts for accessing api's of Google.

Initially there is no option for appengine to use service accounts. No I found this URL which says we can do the same. https://developers.google.com/api-client-library/python/platforms/google_app_engine#ServiceAccounts

I tried out the process couldn't achieve success. On the other part i have two questions.

  1. How this api identifies whats the Google Project Account I have billing in.
  2. The process no where uses the private the key we got from Google Console. And when i tried out this is what i see.

    Traceback (most recent call last): File "/base/data/home/apps/tempid/cons-main.361607602228494295/main.py", line 63, in service = build('drive', 'v2', http=http) File "/base/data/home/apps/tempid/cons-main.361607602228494295/oauth2client/util.py", line 120, in positional_wrapper return wrapped(*args, **kwargs) File "/base/data/home/apps/tempid/cons-main.361607602228494295/apiclient/discovery.py", line 193, in build resp, content = http.request(requested_url) File "/base/data/home/apps/tempid/cons-main.361607602228494295/oauth2client/util.py", line 120, in positional_wrapper return wrapped(*args, **kwargs) File "/base/data/home/apps/tempid/cons-main.361607602228494295/oauth2client/client.py", line 405, in new_request self._refresh(request_orig) File "/base/data/home/apps/tempid/cons-main.361607602228494295/oauth2client/appengine.py", line 162, in _refresh raise AccessTokenRefreshError(str(e)) AccessTokenRefreshError .

Any answers? Pls ignore the error above, i got this sorted out. the error was in defining the scope.

I added my appengine apps service account ID to console, Added billing & am not using any API key.

 service.files().insert(
        body=body,
        ).execute()

This statement throws an exception.

An error occured: <HttpError 403 when requesting https://www.googleapis.com/drive/v2/files?alt=json returned "Daily Limit Exceeded. Please sign up">

I wonder if i have added my appengine service account to 2-3 projects at api console and i am not using any api key where will the data from this project get into. –

Was it helpful?

Solution

Service accounts are only supported with some particular services. It appears you're trying to use the Google Drive SDK, so I added google-drive-sdk tag. Hopefully someone watching that tag can tell you whether Drive supports service accounts.

Provided service accounts are supported with Drive -- please update the post with your exact code. Are you using the correct Google Drive scope when instatiating the AppAssertionCredentials object?

You may wish to try this in the App Engine shell first so you can catch the exceptions easily and check what's inside the exception object. You'll hopefully be able to find the error response returned by the server when trying to get an access token.

You may have to add the App Engine service account e-mail address (from the App Engine console) as a team member on the API Console project. We have to do this to link up for billing/data permissions on BigQuery.

You will not have to use any private key from the APIs console -- App Engine handles the service account creation and key management automatically.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top