<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Firebase SMS OTP</title>
<meta name="author" content="Marut Jaipala">
<meta name="description" content="You can read more details on website https://firebase.google.com/docs/auth/web/phone-auth?authuser=0 enjoy">
<!-- boostrap -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
<!-- Insert these scripts at the bottom of the HTML, but before you use any Firebase services -->
<!-- Firebase App (the core Firebase SDK) is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.3.1/firebase-app.js"></script>
<!-- If you enabled Analytics in your project, add the Firebase SDK for Analytics -->
<script src="https://www.gstatic.com/firebasejs/8.3.1/firebase-analytics.js"></script>
<!-- Add Firebase products that you want to use -->
<script src="https://www.gstatic.com/firebasejs/8.3.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.3.1/firebase-firestore.js"></script>
<script src="https://www.google.com/recaptcha/api.js"></script>
</head>
<body class="container text-center">
<div class="row justify-content-center">
<div class="col-md-6 pt-4 ">
<h1>Firebase Authenticate With SMS OTP </h1>
<div class="input-group mt-4">
<input id="phoneNumber" type="text" class="form-control" placeholder="+66987654321" aria-label="Example text with button addon" aria-describedby="button-addon1">
<button type="button" class="btn btn-primary" onclick="phonesend()">Request_OTP</button>
</div>
<div id="recaptcha-container"></div>
<p></p>
<div id="show_vertify_otp" class="input-group mt-4 " style="display: none;">
<input type="number" id="OTP" class="form-control" placeholder="" aria-label="Example text with button addon" aria-describedby="button-addon1">
<button type="button" class="btn btn-success" onclick="vertify_otp()">Submit</button>
</div>
</div>
</div>
</body>
</html>
<script>
// firebaseConfig is https://console.firebase.google.com/u/0/project/ -> Project setting { IN TITLE : Your apps }
var firebaseConfig = {
apiKey: "",
authDomain: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: "",
measurementId: ""
};
firebase.initializeApp(firebaseConfig);
firebase.analytics();
firebase.auth().languageCode = 'th';
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
function phonesend() {
const phoneNumber = document.getElementById("phoneNumber").value;
const appVerifier = recaptchaVerifier;
firebase.auth().signInWithPhoneNumber(phoneNumber, appVerifier)
.then((confirmationResult) => {
console.log(confirmationResult)
window.confirmationResult = confirmationResult;
document.getElementById('recaptcha-container').style.display = 'none';
document.getElementById('show_vertify_otp').style.display = 'block';
}).catch((error) => {
console.log(error.message)
});
}
function vertify_otp() {
const code = document.getElementById("OTP").value;
confirmationResult.confirm(code).then((result) => {
console.log(result)
const user = result.user;
alert('OTP VERTIFY : Welcome :' + user);
}).catch((error) => {
console.log(error.message)
});
}
</script>
没有合适的资源?快使用搜索试试~ 我知道了~
Firebase_otp_sms:使用JavaScript在Firebase上通过电话号码对OTP进行身份验证
共2个文件
php:1个
gitattributes:1个
5星 · 超过95%的资源 需积分: 10 3 下载量 64 浏览量
2021-03-25
13:22:32
上传
评论
收藏 2KB ZIP 举报
温馨提示
Firebase_otp_sms:使用JavaScript在Firebase上通过电话号码对OTP进行身份验证
资源详情
资源评论
资源推荐
收起资源包目录
Firebase_otp_sms-main.zip (2个子文件)
Firebase_otp_sms-main
.gitattributes 66B
firebase_sms_otp.php 4KB
共 2 条
- 1
陈崇礼
- 粉丝: 47
- 资源: 4683
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- NVIDIA驱动、CUDA和Pytorch及其依赖
- html动态爱心代码一(附源码)
- c40539bc-071a-486c-9d52-9d0c18d62dac 4.html
- 基于物理的非视域成像(NLOS)算法,利用了nerf+python源码+文档说明
- yuluer知更鸟.7z(1).001
- python课程设计-基于tensorflow实现的图文生成程序,数据集flickr30k-images+源代码+文档说明+截图
- python作业-基于Flickr30k数据集实现图像文本跨模态搜索python源码+数据集+测试界面+项目说明(高分课程设计)
- 基于Qt实现医院信息管理系统c++源码+文档说明+数据库(期末大作业)
- 基于python实现的医院信息管理系统完整源码+sql数据库+详细注释(高分课程设计)
- 基于python的眼底图像视杯视盘分割项目源码+文档说明+截图演示+详细注释(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1