Phonegap& Firebase Google Auth问题

时间:2016-10-25 13:04:08

标签: android cordova firebase phonegap-build firebase-authentication

所以我正在创建一个Android手机屏幕应用,我试图整合Firebase。

我从Firebase添加了网络应用程序代码并调用了firebase.auth()然后我会收到错误:

"Refused to display 'https://accounts.google.com/o/openid2/auth
?openid.ns=http://specs.openid.ne…tp://axschema.org/namePerson
/last&openid.ax.required=email,name,first,last'
in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'."

我做了很多研究,但如果有解决方案,我无法理解,因为他们没有完全解释。

如果有帮助,我还安装了inappbrowser吗?

这是我的代码:PS我删除了一些代码以专注于登录部分

<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="no" />
    <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
    <link rel="stylesheet" type="text/css" href="css/index.css"/>
    <!--<link rel="stylesheet" type="text/css" href="css/style.css"/>-->
    <link rel="stylesheet" type="text/css" href="css/swiper.min.css"/>
    <title>SUSU</title>
    <script type="text/javascript" charset="utf-8" src="cordova.js"></script> 
</head>
<body>
    <div class="wrapper">
        <div class="outer-content">
            <div class="pages">
                <div id="login" class="page">
                    <div class="logo"></div>
                    <h1>LOGIN OR REGISTER</h1>
                    <div class="facebook-btn">
                        <div class="icon-container">
                            <span class="icon icon-plus"></span>
                        </div>
                        <span class="text">Sign in with Facebook</span>
                    </div>
                    <div class="google-btn" onclick="googleLogin()">
                        <div class="icon-container">
                            <span class="icon icon-plus"></span>
                        </div>
                        <span class="text">Sign in with Google</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

JS代码:

document.addEventListener("deviceready", function(){
    navigator.splashscreen.show();
    window.setTimeout(function () {
        navigator.splashscreen.hide();
    }, 5000);
},true);

var provider = new firebase.auth.GoogleAuthProvider();
function googleLogin(){

    //var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');

    firebase.auth().signInWithRedirect(provider).then(function(result) {
        console.log(provider, result);
        // This gives you a Google Access Token. You can use it to access the Google API.
        var token = result.credential.accessToken;
        // The signed-in user info.
        var user = result.user;
        // ...
    }).catch(function(error) {
        // Handle Errors here.
        var errorCode = error.code;
        var errorMessage = error.message;
        // The email of the user's account used.
        var email = error.email;
        // The firebase.auth.AuthCredential type that was used.
        var credential = error.credential;
        // ...
    });
}

0 个答案:

没有答案