我一直在使用Google +登录API,
我已经跟踪了包含此内容的错误:
Load denied by X-Frame-Options: https://accounts.google.com/o/oauth2/auth?XXXXXXXX does not permit cross-origin framing.
因此,它不会继续使用网址,因为X-Frame-Options
阻止了网址。
我研究过X-Frame-Options,说它应该在标题中设置。
我将如何在此标题中设置它:
<meta name="google-signin-clientid" content="{{=response.CLIENT_ID}}" />
<meta name="google-signin-scope" content="https://www.googleapis.com/auth/plus.login" />
<meta name="google-signin-requestvisibleactions" content="http://schemas.google.com/AddActivity" />
<meta name="google-signin-cookiepolicy" content="single_host_origin" />
我正以这种方式渲染我的按钮:
(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js?onload=render';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
function render() {
// Additional params including the callback, the rest of the params will
// come from the page-level configuration.
var additionalParams = {
'callback': signinCallback,
'immediate': false,
};
// Attach a click listener to a button to trigger the flow.
var signinButton = document.getElementById('signinButton');
signinButton.addEventListener('click', function() {
gapi.auth.signIn(additionalParams); // Will use page level configuration
});
}
或者设置它的其他方法是什么?或者如何修复这个错误?我的后端部分是python。
答案 0 :(得分:0)
我也有这个问题,但我发现了我的结果。
我正致力于在Golang中创建一个在Google App Engine上运行的应用程序。我获取了设置Google+登录按钮按钮所需的代码段,并将其粘贴到我的模板中。代码看起来像这样,直接来自Google Documentation:
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="CLIENT_ID"
data-cookiepolicy="single_host_origin"
data-requestvisibleactions="http://schema.org/AddAction"
data-scope="https://www.googleapis.com/auth/plus.login">
我没有用CLIENT_ID替换我的真实clientId,这就是问题所在。我用我的Google App Engine CLIENT_ID替换了字符串“CLIENT_ID”,它解决了我的问题。我通过使用Chrome开发者工具在网络选项卡上观看网络请求/响应信息来观察到这一点,并观察到这个奇怪的请求是使用CLIENT_ID,这看起来不对。
在进一步检查代码后,这确实是我的问题。
希望这有帮助!