在Google+中分享了API错误origin_mismatch [英] Got origin_mismatch error in Google+ share api
问题描述
我想分享到谷歌+一些动态内容。对于这个我检查<一个href=\"https://developers.google.com/+/web/share/interactive#rendering_the_button_with_javascript\">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
推荐答案
原产地不一致通常是由不正确设置在 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.
更多细节可以在<一个开发者文档中找到href=\"https://developers.google.com/+/web/signin/javascript-flow#step_1_create_a_client_id_and_client_secret\">\"Create客户端ID和客户端密钥部分。
的注:这里的一个常见的错误是添加JavaScript源对于http://而不是https://开头(反之亦然)。如果你想允许用户从访问您的站点都那么你需要在JavaScript控制台中同时列出。的
的注(感谢伯特利Goka):您必须包括如果一个端口号会出现在URL当用户访问您的站点服务器的JavaScript源端口号的
这篇关于在Google+中分享了API错误origin_mismatch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!