GAS库和WebApp权限[ReferenceError:"service"没有定义.] [英] GAS Library and WebApp Permissions [ReferenceError: "service" is not defined.]

查看:64
本文介绍了GAS库和WebApp权限[ReferenceError:"service"没有定义.]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景/摘要

我一直在广泛使用库,现在正在设置权限,因此我可以将应用分发给某些用户进行测试.不幸的是,这是非常不可预测的.我将问题简化如下:

我有一个简单的webApp,它正在对融合表进行简单的API调用.它在我的Fusion Tables库中调用一个函数.我的Fusion Table库中的函数还使用了我的OAuth库中的函数.从我的主要gmail帐户(所有资源都属于该帐户)执行时,此过程运行良好.但是,我现在正在设置权限,它将无法从另一个帐户使用.从另一个帐户执行此webApp时,出现以下错误(在一种情况下除外,将在后面描述):

ReferenceError:未定义服务".

详细信息&资源

我正在使用Google的oAuthConfig类,该类默认将我设置为OAuth1.0.

权限设置如下:

webApp

  • 执行为:用户访问webApp
  • 有权访问的人:任何人
  • 共享:知道链接的任何人都可以查看

融合表库

  • 执行为:用户访问webApp
  • 有权访问的人:任何人
  • 共享:知道链接的任何人都可以查看

OAuth库

  • 执行为:用户访问webApp
  • 有权访问的人:任何人
  • 共享:知道链接的任何人都可以查看

我的OAuth库代码

OAuth库项目密钥:Mnt39sDQPQvSd3QGZFFLcznt7vnFOnL

融合表库代码

融合表库项目密钥:MigHa1npbg9PnkaJ8jFENSyUlmcxk5wr2

出现错误的简化的WebApp:已发布的WebApp ((下面的代码)

  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'};函数doGet(){var app = UiApp.createApplication();var tempVar = FTL.fusionRequest('GET','SHOW TABLES',oAuthFields);Logger.log('Result:'+ tempVar);app.add(app.createLabel('Success'));返回应用程序;} 

例外

现在,让事情变得更加有趣,如果我将OAuth库的共享"设置从具有链接可以查看的任何人"更改为具有链接可以编辑的任何人",则一切运行正常.我显然不希望拥有我的库的通用编辑权,所以我一直坚持为什么会发生这种情况,以及修复该问题所需要做的事情.

我不清楚在使用库时如何考虑执行为"和共享"设置.我希望任何人都可以访问webApp,并以用户身份执行,并且我将以编程方式实施访问限制.

解决方案

我已将其识别为GAS库中的更新传播错误.我已此处提交了一个问题问题跟踪器.

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.

解决方案

I have identified this as an error with update propagation in GAS libraries. I have submitted an issue here to the issue tracker.

这篇关于GAS库和WebApp权限[ReferenceError:"service"没有定义.]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆