代码之家  ›  专栏  ›  技术社区  ›  gonephishing

如何使用firebase在web上嵌入谷歌登录按钮进行身份验证

  •  5
  • gonephishing  · 技术社区  · 9 年前

    platform.js 脚本,因为它不用于处理身份验证。

    所有功能都由firebase处理。此外,我计划为web使用自定义UI,而不是Firebase UI。

    2 回复  |  直到 9 年前
        1
  •  3
  •   MuruGan    9 年前

    你是否在Firebase中使用angularfire,如果你不使用它,请尝试通过此链接 firebase Google Sign In Method

    如果您正在寻找按钮登录的代码,请按以下方式进行编码,

    <input type="button" onclick=callGoogleSignIn() value="Google Sign In"/>
    <script>
          function callGoogleSignIn(){
              var provider = new firebase.auth.GoogleAuthProvider();
              firebase.auth().signInWithPopup(provider).then(function(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;
                // ...
             });
          }
    </script>
    

    请随时询问任何疑问,如果你有并通过这个网站 For Firebase Google Log in

        2
  •  0
  •   Varad    7 年前

    ###基于firebase的电话认证###

    ###firebase和代码设置###

    1. https://github.com/Varadsingh/google-phone-auth/archive/master.zip
    2. https://console.firebase.google.com/project/
    3. 创建新项目
    4. 现在在“你的应用”部分选择“配置”单选按钮
    5. 复制给定的代码
    6. 您还可以添加虚拟电话号码和验证码以进行测试
    7. 在“授权域”部分,添加您的域,例如“localhost”

    1. 该代码在服务器环境中正常运行,这意味着它不会通过双击html文件来运行
    2. 您需要将代码复制到使用示例XAMPP的服务器上的root/htdocs/public\u html文件夹中