错误:授权Google Analytics嵌入API时origin_mismatch

Error: origin_mismatch when authorizing embed API for Google Analytics

本文关键字:origin mismatch API 嵌入 授权 Google Analytics 错误      更新时间:2023-09-26

我正试图在第三方CMS中实现谷歌分析的统计仪表板,但遇到了一些问题。我正在尝试使用谷歌嵌入API来构建我的仪表板,当我尝试验证我的帐户时遇到了这个错误:

Error: origin_mismatch 

我四处寻找解决方案,很快发现是因为缺少www.。问题是,我在谷歌开发者控制台中填写了正确的URL,但仍然没有运气。有人知道我该怎么解决这个问题吗?

Error: origin_mismatch
Application: CMEZ Analytics
You can email the developer of this application at: email@email.com
Request Details
=
from_login=1
response_type=code token id_token gsession
scope=https://www.googleapis.com/auth/analytics.readonly https://www.googleapis.com/auth/userinfo.email
redirect_uri=postmessage
cookie_policy=single_host_origin
proxy=oauth2relay482041337
include_granted_scopes=true
origin=http://cmez.eu
state=458516662|0.59538506
as=1d7def2550073266
client_id=[censored]
authuser=1
hl=nl
That’s all we know.

origin_mismatch错误可能是由于Javascript源代码没有在项目的Google Developer控制台中正确设置所致。Javascript的来源必须与您的请求来自的域以及您在登录后将用户返回的域相匹配。

注意:这里的一个常见错误是为http://而不是https://添加javascript源代码(反之亦然)。如果url中出现端口号,则还必须将服务器的端口号包含在javascript源中。

文档信息

在Authorized JavaScript originals字段中,输入您的应用程序。您可以输入多个来源以允许应用程序在其上运行不同的协议、域或子域。通配符不是允许。在下面的示例中,第二个URL可能是生产URL。http://localhost:4567
https://myproductionurl.example.com