不是客户端的有效来源:url 尚未为 localhost NOT 127.0.0.1 的客户端 ID 列入白名单

问题描述

在您将其标记为重复之前,我的问题SO1SO2不同,而是两者的混合。

我一打开 :/5500 就得到了: Google 日历 API 快速入门

{
  "error": "idpiframe_initialization_Failed","details": "Not a valid origin for the client: http://localhost:5500 has not been whitelisted for client ID 311....idvc2n.apps.googleusercontent.com. Please go to https://console.developers.google.com/ and whitelist this origin for your project's client ID."
}

尽管如此,我的 OAuth 2.0 项目中有包含 /5000/5500 端口的 URL(ps 我使用来自 API 密钥的 API 密钥和来自 OAuth2.0 ClientID 的客户端 ID)。

但是,一旦我按照 SO1 的建议尝试清除缓存后,它仅适用于 http://127.0.0.1:5500/ 而不适用于 localhost:5500/。当我继续点击授权时,我得到:

Error 400: invalid_request
Permission denied to generate login hint for target domain.

SO2 的答案是使用 localhost 而不是 http://127.0.0.1:5500/,如果我这样做,我会遇到第一个问题循环。

我的代码来自 js quickstart。我还尝试根据 SO1 建议启用 Google Plus 和 Google Analytics API。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)