[英]Adding Javascript-only script of "https://apis.google.com/js/api.js"
我正在开发这个附加功能,当用户单击一个按钮时,它会连接到 Google 电子表格。 我关注了 https://developers.google.com/sheets/api/quickstart/js#python-3.x ,但我不想从控制台启动我的插件。 有什么办法可以将它作为附加组件启动,而不是“python -m http.server 8000”? 另外,我发现gapi.load('client:auth2', initClient)
在我的插件中不起作用。 I noticed the tutorial runs on https://localhost:8000, so I added https://my.wasabi.edu (the domain I work on) to "Authorized Javascript Origins" but it only loaded apis.google.com. 是否与 http.server、XML 或“授权 Javascript 起源”有关?
这就是我加载 apis.google.com 的方式
let script = document.createElement("script")
script.src = "https://apis.google.com/js/api.js"
script.type = "text/javascript"
script.async = true
script.defer = true
script.onload = () => {
handleClientLoad()
}
document.head.appendChild(script)
加载 auth2 和 API 客户端库
function handleClientLoad() {
gapi.load('client:auth2', initClient);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.