首页 > 解决方案 > 不是客户端的有效来源: url 没有被列入 localhost NOT 127.0.0.1 的客户端 ID 白名单

问题描述

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

我一打开我:/5500就得到了:Google Calendar API Quickstart

{
  "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 项目中有一个 URL,它同时包含/5000/5500端口(ps 我使用来自 API 密钥的 API 密钥和来自 OAuth2.0 ClientIDs 的客户端 ID)。

但是,一旦我按照SO1建议尝试 SO 清除缓存,它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 分析 API。

标签: javascriptgoogle-apigoogle-calendar-api

解决方案


推荐阅读