gpt4 book ai didi

javascript - Google Picker API Invalid origin value 错误

转载 作者:行者123 更新时间:2023-12-03 15:39:51 25 4
gpt4 key购买 nike

今天,Google Picker 停止在我的 Google Sheets 插件中工作,而无需对代码进行任何更改。模态对话中的错误如下:

Invalid origin value.


控制台中的错误是:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://docs.google.com') does not match the recipient window's origin ('https://n-a6p4dqsl***d6wq-0lu-script.googleusercontent.com')

dropping postMessage.. was from unexpected window

dropping postMessage.. was from unexpected window

Invalid 'X-Frame-Options' header encountered when loading 'https://docs.google.com/picker?protocol=gadgets&origin=https%3A%2F%2Fdocs.google.com%2F&sdr=true&title&oauth_token=<oathToken>&developerKey=<developerKey>&hostId=n-a6p4dq***d6wq-0lu-script.googleusercontent.com&relayUrl=https%3A%2F%2Fn-a6p4dq***d6wq-0lu-script.googleusercontent.com%2Ffavicon.ico&nav=((%22documents%22%2Cnull%2C%7B%22selectFolder%22%3Atrue%2C%22parent%22%3A%22root%22%7D)%2C(%22documents%22%2Cnull%2C%7B%22dr%22%3Atrue%2C%22includeFolders%22%3Atrue%7D))&rpcService=qhurmoc5w4l7&rpctoken=xssf8g42xc2&thirdParty=true#rpctoken=xssf8g42xc2': 'ALLOW-FROM https://docs.google.com/' is not a recognized directive. The header will be ignored.


可能错误与我执行 setOrigin() 的这行代码有关。 :
        var picker = new google.picker.PickerBuilder()
.addView(driveView)
.addView(drivesView)
.hideTitleBar()
.setOAuthToken(token)
.setDeveloperKey(DEVELOPER_KEY)
.setCallback(pickerCallback)
--> .setOrigin(google.script.host.origin)
.setSize(DIALOG_DIMENSIONS.width - 2,
DIALOG_DIMENSIONS.height - 2)
.build();
但是这一行直接来自 Google Picker API 的文档,并且之前可以正常工作。如果我改变 google.script.host.origin ,返回 https://docs.google.com作为 https://n-a6p4dqsl***6wcd6wq-0lu-script.googleusercontent.com 的网址,我得到了同样的错误和一个新的错误,所以不是这样。
我也无法将其添加为 GCP 项目中的授权 javascript 来源,因为它返回以下错误:

Invalid Origin: uses a forbidden domain


(此 has been the case of a while )
这似乎是一个新错误,我在 Google 的问题跟踪器和 StackOverflow 上都找不到答案。
任何人都面临这个问题或知道如何处理它?

最佳答案

结束,解决这个问题的唯一方法是在

docs.google.com/

docs.google.com
相反,
google.script.host.orgin 给出了导致错误的“https://docs.google.com/”。因此,您需要硬编码为
“https://docs.google.com”
谷歌最近做了一些改变,这可能会引发这个问题。
更新
您可以使用此功能 - 并调用 - ...... setOrigin(getOrigin())

function getOrigin() {
var url = google.script.host.origin;
return url.substr(url.length - 1) === "/" ? url.substr(0, url.length - 1) : url;
}

关于javascript - Google Picker API Invalid origin value 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65632969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com