javascript - Google 身份验证导致 origin_mismatch 错误。

标签 javascript jquery google-oauth google-analytics-api

我已经完成了获取谷歌分析帐户列表的代码 并且它与静态 clientid 一起工作正常

我使用过这个教程:Hello Analytics API: JavaScript quickstart for web applications

问题是:

我希望所有用户都能使用此功能,这意味着我的用户从他们的 Google 帐户登录,并且他们都可以看到他们的 Google Analytics(分析)帐户列表。

但是我看到一个错误:“origin_mismatch”

我希望不设置原点,因为我无法为所有用户设置原点。

最佳答案

来源不匹配通常是由于google developers console项目中的Javascript来源不正确引起的。检查并确保 Javascript 来源与您发出请求的域以及登录后将用户返回到的域相匹配。

Creating a Google API Console project and client ID

In the Authorized JavaScript origins field, enter the origin for your app. You can enter multiple origins to allow for your app to run on different protocols, domains, or subdomains. You cannot use wildcards. In the example below, the second URL could be a production URL.
http://localhost:8080
https://myproductionurl.example.com

回答:如果您使用 JavaScript,则需要设置要向其返回身份验证的服务器的来源。这是没有办法解决的。只需添加您的服务器,您的用户就可以访问它。无需为每个用户进行设置。来源是托管脚本的服务器。

关于javascript - Google 身份验证导致 origin_mismatch 错误。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40152036/

相关文章:

javascript - Chrome 中鼠标滚轮 DOMMouseScroll 的 PreventDefault() 错误

javascript - 如何使用jquery将结果放在最后

oauth-2.0 - 谷歌 OAuth "error": "invalid_grant" response to request to exchange one time auth code for refresh and access token

oauth-2.0 - Google Oauth token 限制

javascript - 如何更改 nvd3 中图例文本的字体?

javascript - Tumblr 上的移动设备检测

javascript - Spring boot,WebSocket不向指定用户发送通知

javascript - 选择第一个下拉列表时,相关下拉列表未加载

authentication - 如何在没有 Google Dll 的情况下验证 Gmail API

jquery - 悬停 td 时隐藏所有表格