简体   繁体   English

使用 FirebaseUI 身份验证组件时如何让 reCAPTCHA 工作?

[英]How can I have the reCAPTCHA work when using FirebaseUI auth component?

I'm creating a web app using Polymer to build the front-end, and I'm using FirebaseUI component as a drop-in to support Firebase Phone Authentication, but immediately the page renders that has the FirebaseUI component on it I'm getting this error in my console logs: Uncaught DOMException: Blocked a frame with origin "https://www.google.com" from accessing a cross-origin frame.我正在使用 Polymer 创建一个 Web 应用程序来构建前端,并且我正在使用 FirebaseUI 组件作为插件来支持 Firebase 电话身份验证,但立即呈现的页面上有 FirebaseUI 组件我得到我的控制台日志中出现此错误: Uncaught DOMException: Blocked a frame with origin "https://www.google.com" from accessing a cross-origin frame. And after that the reCAPTCHA won't be solved.之后, reCAPTCHA将无法解决。 I want to use firebase phone authentication in the app I'm building.我想在我正在构建的应用程序中使用 firebase 电话身份验证。

I tried running the app both on my local dev server serving it on http but still behaving just the same even when I run on firebase ( https ).我尝试在我的本地开发服务器上运行该应用程序,并在http为其提供服务,但即使我在 firebase ( https ) 上运行,其行为仍然相同。 I tried to open an issue on github but still no helpful response was gotten.我试图在 github上打开一个问题,但仍然没有得到有用的回应。

Below is the code that's in charge of configuring and specifying the location where the FirebaseUI phone auth component should be rendered.下面是负责配置和指定 FirebaseUI 电话身份验证组件应呈现的位置的代码。

ready() {
        super.ready();
        // FirebaseUI config.
        var uiConfig = {
            signInSuccessUrl: `${window.location.origin}/seller-dashboard`,
            signInOptions: [
                {
                    provider: firebase.auth.PhoneAuthProvider.PROVIDER_ID,
                    recaptchaParameters: {
                        type: 'image', // 'audio'
                        size: 'normal', // 'invisible' or 'compact'
                        badge: 'bottomleft' //' bottomright' or 'inline' applies to invisible.
                    },
                    defaultCountry: '+260'
                }
            ],
            // tosUrl and privacyPolicyUrl accept either url string or a callback
            // function.
            // Terms of service url/callback.
            tosUrl: `${window.location.origin}/terms`,
            // Privacy policy url/callback.
            privacyPolicyUrl: function () {
                window.location.assign(`${window.location.origin}/privacy`);
            }
        };

        // Initialize the FirebaseUI Widget using Firebase.
        var ui = new firebaseui.auth.AuthUI(firebase.auth());
        // The start method will wait until the DOM is loaded.
        ui.start(this.$.container, uiConfig);
    }

When the page where the firebaseui phone authentication component is is rendered I'm having these console logs on Google Chrome: XHR finished loading: GET "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getRecaptchaParam?key=AIzaSyAUb_eFUs_zNJ5HMtlRV3Ghg1JLQ63enL4&cb=1558695304328". recaptcha__en.js:529当呈现firebaseui phone authentication组件的page ,我在 Google Chrome 上有这些console logsXHR finished loading: GET "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getRecaptchaParam?key=AIzaSyAUb_eFUs_zNJ5HMtlRV3Ghg1JLQ63enL4&cb=1558695304328". recaptcha__en.js:529 XHR finished loading: GET "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getRecaptchaParam?key=AIzaSyAUb_eFUs_zNJ5HMtlRV3Ghg1JLQ63enL4&cb=1558695304328". recaptcha__en.js:529

Uncaught DOMException: Blocked a frame with origin "https://www.google.com" from accessing a cross-origin frame. at wG.K.l9 (https://www.gstatic.com/recaptcha/api2/v1558333958099/recaptcha__en.js:529:183) at yu (https://www.gstatic.com/recaptcha/api2/v1558333958099/recaptcha__en.js:532:11) at Object.init (https://www.gstatic.com/recaptcha/api2/v1558333958099/recaptcha__en.js:542:72) at https://www.google.com/recaptcha/api2/bframe?hl=en&v=v1558333958099&k=6LcMZR0UAAAAALgPMcgHwga7gY5p8QMg1Hj-bmUv&cb=2zr5gn9cy630:184:30

I'm running everything on macOS Mojave , browser: Google Chrome 74.0.3729.157 , Firebase UI version: 6.0.2 , and Polymer 3.我在macOS Mojave上运行所有内容,浏览器: Google Chrome 74.0.3729.157 ,Firebase UI 版本: 6.0.2和 Polymer 3。

Any help how I can have this work?任何帮助我如何才能完成这项工作?

This isn't a problem and verification should work regardless;这不是问题,无论如何验证都应该有效; Firebase's demo shows the same error.I had the exact same issue, but after hours of attempts realised I made the silly mistake of adding my mobile number in the console as a number for testing. Firebase 的演示显示了相同的错误。我遇到了完全相同的问题,但经过数小时的尝试后意识到我犯了一个愚蠢的错误,将我的手机号码添加到控制台中作为测试号码。 FB won't send you a code in this case, and you will have to specify the verification you specified in the console.在这种情况下,FB 不会向您发送代码,您必须指定您在控制台中指定的验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM