简体   繁体   English

App Script Go快速入门修改401错误

[英]App Script Go Quickstart modification 401 error

I am trying out this tutorial on Go and App Script and it works perfectly but the moment I modified the code to access a spreadsheet the go part doesn't execute the script but give a 401 error. 我正在尝试使用Go和App Script编写本教程, 并且效果很好,但是当我修改代码以访问电子表格时,go部件不会执行脚本,但会出现401错误。 Here is my go code (basically code from the tutorial but changed a few things for it to 'work' on my app script) http://pastebin.com/28S5tVY2 这是我的执行代码(基本上是教程中的代码,但是将其更改为在我的应用程序脚本上可以“运行”) http://pastebin.com/28S5tVY2

I don't know if I made a mistake when creating credentials for the script (I have redone this severally with no success) or if I missed something while doing the modification. 我不知道在为脚本创建凭据时是否犯了错误(我多次重做都没有成功)还是在修改时错过了某些内容。 Any help will be highly appreciated. 任何帮助将不胜感激。

As suggested by @Mogsdad, I looked into adding scopes. 正如@Mogsdad所建议的那样,我研究了添加范围。 On the target App Script, click on File >> Project Properties >> Scopes to get what scopes you need to add. 在目标应用脚本上,单击文件>>项目属性>>范围,以获取需要添加的范围。 An example of a scope is " https://www.googleapis.com/auth/spreadsheets ". 范围的示例是“ https://www.googleapis.com/auth/spreadsheets ”。

On the Golang code, add the scope like so: 在Golang代码上,如下添加范围:

config, err := google.ConfigFromJSON(b, https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/spreadsheets") 

Hope this helps someone :) 希望这对某人有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 针对 GO 错误的 Google Glass 快速入门 - Google Glass Quickstart for GO Errors 是否有人能够获得Go Hello World快速入门演示,以适用于Google App Engine托管的VM? - Has anyone been able to get the Go Hello World Quickstart demo to work for Google App Engine Managed VMs? 使用Go的App脚本AppEngine教程 - App script appengine tutorial using Go 当cURL正常工作时,从Go代码中使用API​​时出现401错误 - 401 Error when consuming an API from Go Code, while cURL Works well 拉出单行标准包装的副本以进行修改 - Pull a copy of a single go standard package for modification Amazon AWS S3的GO脚本运行时错误 - GO script runtime error for Amazon AWS S3 App Engine / Go:“ goapp服务”给出错误“无法构建Go应用程序”错误 - App Engine/Go: 'goapp serve' giving an error “Go application could not be built” error Firebase Admin SDK GO VerifyIDToken 不返回 App Engine 上下文错误 - Firebase Admin SDK GO VerifyIDToken returns not an App Engine context error 是否可以在Google App Engine上使用Go设置默认错误页面 - Is it possible to set a default error page using Go on Google App Engine Go gmail api 快速启动导致本地主机拒绝连接 ERR_CONNECTION_REFUSED - Go gmail api quickstart results in localhost refused to connect ERR_CONNECTION_REFUSED
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM