在 Google+ 共享 api 中出现 origin_mismatch 错误 [英] Got origin_mismatch error in Google+ share api

查看:28
本文介绍了在 Google+ 共享 api 中出现 origin_mismatch 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 google+ 上分享一些动态内容.为此,我检查了它 https://developers.google.com/+/web/share/interactive#rendering_the_button_with_javascript

I want to share some dynamic content on google+. For this I checked it https://developers.google.com/+/web/share/interactive#rendering_the_button_with_javascript

<head>
<script type="text/javascript">
  (function() {
   var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
   po.src = 'https://apis.google.com/js/client:plusone.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 })();
</script>
</head>
<body>
<button
  class="g-interactivepost"
  data-contenturl="http://www.pubandbar-network.co.uk/" 
  data-clientid="102180630313.apps.googleusercontent.com"
  data-cookiepolicy="single_host_origin">  Share 
</button>
</body>

但是在执行时我收到此错误

But when executing I am getting this error

Error: origin_mismatch
Request Details

    scope=https://www.googleapis.com/auth/plus.login
    response_type=code token id_token gsession
    access_type=online
    redirect_uri=postmessage
    cookie_policy=single_host_origin
    proxy=oauth2relay554026710
    origin=http://www.pubandbar-network.co.uk
    state=1995523240|0.4607792083184853
    display=page
    client_id=102180630313.apps.googleusercontent.com
    authuser=0

请建议如何解决这个问题

Please suggest how to fix this

推荐答案

Origin mismatch 通常是由于 中未正确设置 Javascript 来源造成的API 项目控制台.您需要确保 Javascript 来源与您的请求来自的域以及您在登录后返回用户的域相匹配.

Origin mismatch is normally caused by the Javascript origins not being set correctly in the API project console. You need to make sure that the Javascript origins match the domain from which your requests are coming and to which you are returning the user after sign in.

更多详细信息可以在开发者文档中找到 创建客户端 ID 和客户端密钥" 部分.

More details can be found in the developer documentation in the "Create a client ID and client secret" section.

注意:这里的一个常见错误是为 http://添加 javascript 来源,而不是 https://(反之亦然).如果您想允许用户从这两个站点访问您的站点,那么您需要在 javascript 控制台中列出这两个站点.

注意(感谢 Bethel Goka):如果用户访问您的网站时 URL 中出现端口号,则您必须在 javascript 源中包含服务器的端口号.

这篇关于在 Google+ 共享 api 中出现 origin_mismatch 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆