我正在为我的新手机游戏开发一个社区网站,并尝试向其中添加 google plus 登录流程。
实施过程中采取的步骤:
-> 已关注this https://developers.google.com/+/web/signin/add-button谷歌开发者教程
HTML 按钮代码:
<span id="signinButton">
<span
class="g-signin"
data-callback="onSignInCompleted"
data-clientid="<myID>.apps.googleusercontent.com"
data-cookiepolicy="single_host_origin"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-scope="https://www.googleapis.com/auth/plus.login">
</span>
</span>
Javascript 加载代码:(就在主体关闭之前)
<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>
问题:
-> 实现在本地主机上运行良好
-> 该实现无法在线运行(即上传到服务器上)
在线页面奇怪的行为:
-> 按钮没有被渲染
-> 签名的回调不会被调用
我的网络应用程序 OAuth 2.0 javascript 起源:
https://fcouceiro.com
https://www.fcouceiro.com
http://www.fcouceiro.com
http://fcouceiro.com
http://meatify:8888
我目前使用 fcouceiro.com 作为来源,但想法是在解决此问题后使用 eatify.fcouceiro.com 子域。
更新:经过一些实验,我发现有时(比如您第一次访问该页面)它确实会被渲染(按钮)。所以我认为问题可能是在 html 之后加载脚本。因为我正在使用 jQuery 加载函数来加载包含登录按钮的 html 页面。然后 onload 被调用,脚本尝试找到我的按钮,但它不可用。你怎么认为?
您可以在这里找到我的页面:http://fcouceiro.com http://fcouceiro.com
应用编码!