Firebase web phone number authentication without Firebase UI.
See original GitHub issueI’ve been googling for 2 days for html and JavaScript code for adding firebase phone number authentication in my website. I saw the firebaseui doing this job. But it has their own form elements. I haven’t found any articles or videos showing "how to make Firebase web auth with phone number, without using Firebaseui/nodejs. Is it really possible to do this with my own textbox and other buttons? I had written a code for this and it’s not working. Please do a checkup or prefer any best articles, show the exact thing I want. The code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Untitled</title>
<script src="https://www.gstatic.com/firebasejs/4.6.2/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyBA-sB86rtEQRdyMInGIHHbAv1QAr6QMaw",
authDomain: "mcent-hack.firebaseapp.com",
databaseURL: "https://mcent-hack.firebaseio.com",
projectId: "mcent-hack",
storageBucket: "mcent-hack.appspot.com",
messagingSenderId: "489625162227"
};
firebase.initializeApp(config);
</script>
</head>
<body>
<script>
var phoneNumber = getPhoneNumberFromUserInput();
var appVerifier = window.recaptchaVerifier;
firebase.auth().signInWithPhoneNumber(phoneNumber, appVerifier)
.then(function (confirmationResult) {
alert('sms sent');
// SMS sent. Prompt user to type the code from the message, then sign the
// user in with confirmationResult.confirm(code).
window.confirmationResult = confirmationResult;
}).catch(function (error) {
// Error; SMS not sent
// ...
alert('sms not send');
});
</script>
<form>
<input type="tel" id="number">
<input type="number" id="otp_code">
<input type="submit">
</form>
</body>
</html>
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Authenticate with Firebase with a Phone Number Using ...
The easiest way to add phone number sign-in to your app is to use FirebaseUI, which includes a drop-in sign-in widget that implements...
Read more >Authenticate on Firebase with phone number - Stack Overflow
Fetch Email id of user from Firebase database by passing user provided phone no · If no email id returns, show error that...
Read more >Phone Authentication - FlutterFire
Phone authentication allows users to sign in to Firebase using their phone as the authenticator. An SMS message is sent to the user...
Read more >Getting Started with Firebase for the Web - Authentication
Firebase Authentication web example covering how to get started with Firebase web authentication services including an example of using Firebase ...
Read more >Firebase Authentication with Phone Number OTP in Android
After connecting your app to Firebase. Make sure to add this dependency in your build.gradle file if not added. After adding this dependency ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah I got a working code. This is my one other GitHub account. This is what I did for phone number verification.
I was just requiring service, which can be used for checking if the visitor owns the entered number. This code does that for me. You can change the JavaScript redirection address into something like “login_completion.php?data={Verified phone number (can be the encrypted one)}& Verified=true” so that you can pass the really verified phone number into another PHP file. Then in that file, you can just get the data from current page address and insert the new verified phone number into any databases like phpMyadmin mysql.
@vayshak I could not understand what your issue was. I’m closing this because the original issue has been answered but if you still need assistance with FirebaseUI @vayshak feel free to re-open a new issue.