Go and Google Apps Script Execution API

blov · · 773 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi all, apparently it&#39;s possible to run Google Apps Scripts via Go on App Engine by using the Google Apps Script Execution API, outlined here: <a href="https://developers.google.com/apps-script/guides/rest/api">https://developers.google.com/apps-script/guides/rest/api</a></p> <p>Google has a quick start published for Go here: <a href="https://developers.google.com/apps-script/guides/rest/quickstart/go">https://developers.google.com/apps-script/guides/rest/quickstart/go</a></p> <p>I&#39;ve tried to get this quickstart working several times and even following the steps exactly I keep getting authentication errors.</p> <p>Anyone have experience with this, or have links to some good extra documentation or help for this quickstart?</p> <p>Thanks in advance for any help :)</p> <p>UPDATE: It definitely has something to do with the Apps Scripts end of things. I tried creating a project in the dev console at console.developers.google.com and associated my target Apps Script to this new project, and I was able to get it to run, authenticate, and get a result returned.</p> <p>I&#39;m curious what EXACTLY caused it to work or not work. So I tried the following:</p> <p>I tried configuring a new target Apps Script, copy-pasted the same code into the new Apps Script, followed all the same steps and used the same go code (just updated the script reference)... and it doesn&#39;t work. Did it many times over, trying things in different orders etc. like publishing before switching it to a different project in the dev console etc.</p> <p>I&#39;m wondering if there&#39;s a change to the dev console that wasn&#39;t accounted for in the tutorial documentation.</p> <p>The error I receive is: Unable to execute Apps Script function. googleapi: Error 401: ScriptError, unauthorized exit status 1</p> <p>If I put the wrong name for the function I&#39;m calling in my go code, the error is exactly the same. If I put the wrong name for the function in the Apps Script the error is also exactly the same. I&#39;m thinking this must indicate the issue is 100% before the Apps Script code runs.</p> <p>Thoughts?</p> <hr/>**评论:**<br/><br/>fr4nk3n: <pre><p>In your Developers Console, did you enable &#34;Google Apps Script Execution API&#34;? And also under Credentials did you add a new &#34;OAuth 2.0 client ID&#34; credential (and download the json file for the credential)? Do you get the message saying &#34;Go to the following link in your browser then type the authorization code&#34;?</p></pre>Rabiesalad: <pre><p>Yes to all, after copy-pasting the authorization code it says unauthorized. Does the script all work as-is for you?</p> <p>I have another Google apps account I will try this with to see if the outcome is different. Any other ideas?</p> <p>Thanks for your help :)</p></pre>Rabiesalad: <pre><p>Hey fr4nk3n, I posted an update to my original post, maybe you can help shed some light if you have experience with the dev console and stuff.</p> <p>Thanks!</p></pre>fr4nk3n: <pre><p>Yeah that seems strange, I was able to reproduce the error you got &#34;Unable to execute Apps Script function. googleapi: Error 401: ScriptError, unauthorized exit status 1&#34;. Seems like it could be a change to the dev console that wasn&#39;t accounted for in the tutorial, I know it has changed some in the last few months.</p></pre>Rabiesalad: <pre><p>Thanks for reproducing, let me know if you happen across any other useful info. What a pain :/</p> <p>I had it working, then I copy-pasted stuff into the apps script which still included the original function that worked originally... suddenly I can no longer call that function.</p> <p>I&#39;ll try again today after it&#39;s had time to sit, maybe it&#39;s just some weird propagation issue with the execution api?</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

773 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传