Reputation: 31
Simply speaking, I have set up a "Google Apps Script Execution API" by following this guide: https://developers.google.com/apps-script/guides/rest/quickstart/python
I can call the Executable API from a local Python program with my client secret as described in the guide. No problem there.
But I actually want to call the API from Google App Engine with the same Google account. So, I thought "Service Account" might be the solution.
Therefore, I changed the way the credentials object is created to:
from oauth2client.appengine import AppAssertionCredentials
credentials = AppAssertionCredentials(
'https://www.googleapis.com/auth/sqlservice.admin')
Reference: developers.google.com /api-client-library/python/auth/service-accounts
But my Google App Engine web application is throwing this error:
INFO 2016-01-19 09:16:22,287 client.py:570] Attempting refresh to obtain initial access_token
WARNING 2016-01-19 09:16:22,297 urlfetch_stub.py:540] Stripped prohibited headers from URLFetch request: ['content-length']
{
"error": {
"code": 403,
"message": "Project has not enabled the API. Please use Google Developers Console to activate the 'script' API for your project.",
"errors": [
{
"message": "Project has not enabled the API. Please use Google Developers Console to activate the 'script' API for your project.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}
I have already enabled the "Scripts Execution API" in both my scripts project and Google App Engine project. Can somebody please help? Thanks very much
Upvotes: 3
Views: 511
Reputation: 5985
The AppAssertionCredentials is not the same as the User credential on App Engine for the logged in user. This will only allow you to access 'data stored under an account assigned to the App Engine application itself'. The Google Apps Script Execution API example you linked to specifically needs to access data as a real Google Apps user.
In your case you would probably want to use the OAuth2DecoratorFromClientSecrets with the same client secrets file you are using locally, but uploaded along with your App Engine application.
Upvotes: 0