首页 > 解决方案 > What is the Authorized Javascript Origin for a webapp powered by Google Script?

问题描述

I'm building a webapp with the Google Script engine. Te application uses the Sign in With Google button to log in, so I need a project with a Credential in the Google Cloud Platform which asks me to introduce a domain in the Authorized JavaScript Origin field. Domains of the kind xxx.googleusercontent.com used to work but now they appear to be forbidden. Google Cloud Platform Credentials

Since the app is hosted by Google Script platform, I've tried the URI https://script.google.com, but it does not work. It keeps on saying:

Not a valid origin for the client: https://n-lvkfgw4qjsttvut5eeun3inieub2bbse7ukpiti-0lu-script.googleusercontent.com has not been registered for client ID 577491057122-qlfn0853m85t0u7gsd4rr69rulghts54.apps.googleusercontent.com. Please go to https://console.developers.google.com/ and register this origin for your project's client ID." ​ error: "idpiframe_initialization_failed"

Does anybody know anything about this issue?

标签: authenticationgoogle-apps-scriptoauth-2.0google-signincredentials

解决方案


回答:

在 Google 的问题跟踪器上报告的一个错误上对此进行了讨论 - 由于安全问题,这已被禁止。因此,目前根本没有将 Apps Script Web App 用作 JavaScript 源的方法。

更多信息:

有问题的错误报告:

由于似乎没有关于这一变化的公开信息,因此进行了调查。2021 年 3 月 31 日,一位 Google 员工最终做出了回应,解释了更改的原因,并将问题作为预期行为关闭:

当前使用 OAuth 2.0 的政策要求应用程序在您拥有的域上使用安全的 JavaScript 源和重定向。虽然允许使用某些共享域(例如在 *.web.app 上运行的 Firebase 应用程序),但*.googleusercontent.com为了确保用户帐户的安全和隐私,禁止使用 OAuth 源或重定向 URI。

已更新重定向 URI 验证规则中的文档,并更新了JavaScript 源验证规则以反映这一点:

主机域不能是“googleusercontent.com”。


推荐阅读