问题
Background / Summary
I have been using libraries extensively and I am now getting my permissions setup so I can distribute the app to some users for testing. Unfortunately, it's being very unpredictable. I've simplified the problem as follows:
I have a simple webApp that is making a simple API call to a fusion table. It calls a function in my Fusion Tables Library. The function in my Fusion Table Library also uses a function from my OAuth Library. This process has worked perfectly when executing from my primary gmail account (to which all resources belong). However, I am now setting up the permissions and it will not work from another account. When executing this webApp from another account, I get the following error (except under one scenario, described later):
ReferenceError: "service" is not defined.
Detail & Resources
I am using Google's oAuthConfig class which defaults me to OAuth1.0.
Permissions are set as follows:
webApp
- Execute as: user accessing the webApp
- Who has access: anyone
- sharing: Anyone who has the link can view
Fusion Table Library
- Execute as: user accessing the webApp
- Who has access: anyone
- sharing: Anyone who has the link can view
OAuth Library
- Execute as: user accessing the webApp
- Who has access: anyone
- sharing: Anyone who has the link can view
My OAuth Library Code
OAuth Library Project Key: Mnt39sDQPQvSd3QGZFFLcznt7vnFOnL
Fusion Table Library Code
Fusion Table Library Project Key: MigHa1npbg9PnkaJ8jFENSyUlmcxk5wr2
The simplified webApp that reproduces error: Published webApp (code below)
var oAuthFields = {
'clientId' : '{...}',
'scope' : 'https://www.googleapis.com/auth/fusiontables',
'fetchUrl' : 'https://www.googleapis.com/fusiontables/v1/',
'clientSecret' : '{...}',
'fusionId' : '{...}',
'service' : 'fusiontables',
'queryUrl' : 'https://www.google.com/fusiontables/api/query'
};
function doGet() {
var app = UiApp.createApplication();
var tempVar = FTL.fusionRequest('GET', 'SHOW TABLES', oAuthFields);
Logger.log('Result: ' + tempVar);
app.add(app.createLabel('Success'));
return app;
}
Exceptions
Now to make matters more interesting, if I change the "sharing" settings of the OAuth Library from 'Anyone who has the link can view' to 'Anyone who has the link can edit', everything works perfectly. I obviously do not want universal editing rights to my library so I am stuck on why that happens, as well as what I need to do to fix it.
I am not completely clear on how the 'execute as' and 'sharing' settings are taken into account when using libraries. I am hoping to have the webApp accessible by anyone, executed as the user, and I will implement access restrictions programmatically.
回答1:
I have identified this as an error with update propagation in GAS libraries. I have submitted an issue here to the issue tracker.
来源:https://stackoverflow.com/questions/15867528/gas-library-and-webapp-permissions-referenceerror-service-is-not-defined