简体   繁体   中英

Firebase user phone number verification

I can see that Firebase has phone number authentication but all I want is just to verify the phone number. I do not want to sign in using the phone number. Can I achieve this or should I use other service for sms verification?

Verifying the phone number is part of signing the user in to Firebase Authentication. You cannot use Firebase phone number authentication without signing the user in to Firebase Authentication.

That said: there are many situations where you can likely leave the user signed in to Firebase without problems.

you can just use this

import React from "react";
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
import firebase from "firebase";
import './firebaseui-styling.global.css';

const config = {
  // your firebase config
};

firebase.initializeApp(config);



const PhoneVerification = () => {

    const uiConfig = {
        signInFlow: 'popup',
        signInOptions: [
            {
                provider: firebase.auth.PhoneAuthProvider.PROVIDER_ID,
                recaptchaParameters: {
                    type: 'image',
                    size: 'invisible',
                    badge: 'bottomleft'
                },
                defaultCountry: '+91',
                whitelistedCountries: ['IN', '+91']
            }
        ],
        // callbacks: {
        //     signInSuccessWithAuthResult: function (authResult) {
        //         var no = firebase.auth.PhoneAuthCredential
        //         console.log(no)
        //     }
        // }
    }

    return (
        <div>
            <StyledFirebaseAuth uiConfig={uiConfig} firebaseAuth={firebase.auth()} />
        </div >
    )
}

export default PhoneVerification

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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