Use the API to register your user using phone number [API-KEY][PHONE NUMBER]
1. Format the QR code payload as: [BaseURL][API-KEY][PHONE NUMBER]
URL:
https://smatter3fa-default-rtdb.firebaseio.com/api/[api-key][phone-number-with-country-code].json
2. Copy QR code content to System clipboard
3. Manual Registration Flow: When the user clicks the Register button, copy the generated QR code data to the system clipboard and redirect the user to open the Smatter3FA application.
After QR Verification - Get Response Data A post verification button-manual needs to be added which will be pressed once user has scanned the QR on Smatter 3FA
curl "https://smatter3fa-default-rtdb.firebaseio.com/response/[api-key][phone-number-with-country-code].json"
import java.io.*;
import java.net.*;
public class FirebaseGetResponse {
public static void main(String[] args) {
try {
String url = "https://smatter3fa-default-rtdb.firebaseio.com/response/[api-key][phone-number-with-country-code].json";
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) response.append(inputLine);
in.close();
System.out.println("Response:\\n" + response.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
import requests
url = "https://smatter3fa-default-rtdb.firebaseio.com/response/[api-key][phone-number-with-country-code].json"
response = requests.get(url)
if response.status_code == 200:
print("Response:", response.json())
else:
print("Error:", response.status_code)
fetch("https://smatter3fa-default-rtdb.firebaseio.com/response/[api-key][phone-number-with-country-code].json")
.then(response => response.json())
.then(data => console.log("Response:", data))
.catch(error => console.error("Error:", error));
const axios = require('axios');
axios.get('https://smatter3fa-default-rtdb.firebaseio.com/response/[api-key][phone-number-with-country-code].json')
.then(res => console.log(res.data))
.catch(err => console.error(err));
Send a POST authentication request with a microsecond timestamp payload, then verify the response after 6 seconds.
Authentication Request URL (POST):
https://smatter3fa-default-rtdb.firebaseio.com/Database/PublicAPIAuthenticationRequests/[api-key][phone-number-with-country-code].json
Verification Check URL (GET):
https://smatter3fa-default-rtdb.firebaseio.com/response/[api-key][phone-number-with-country-code].json
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
public class VerificationClient {
private static final String BASE_URL = "https://smatter3fa-default-rtdb.firebaseio.com";
private final HttpClient http = HttpClient.newHttpClient();
public void verificationApi(String apiKey, String phoneNumber) {
long microseconds = ChronoUnit.MICROS.between(Instant.EPOCH, Instant.now());
String jsonPayload = "\"" + microseconds + "abc123\"";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL + "/Database/PublicAPIAuthenticationRequests/" + apiKey + phoneNumber + ".json"))
.header("Content-Type", "application/json; charset=utf-8")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
http.sendAsync(request, HttpResponse.BodyHandlers.discarding())
.exceptionally(e -> null) // Mirrors your empty catch(e) {} block
.thenRunAsync(
() -> checkVerification(apiKey, phoneNumber), // Or checkLiveVerification(phoneNumber)
CompletableFuture.delayedExecutor(6, TimeUnit.SECONDS)
);
}
public void checkVerification(String apiKey, String phoneNumber) {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL + "/response/" + apiKey + phoneNumber + ".json"))
.GET()
.build();
http.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenAccept(response -> {
if (response.statusCode() == 200) {
if (response.body() != null && response.body().contains("success")) {
// SUCCESS
} else {
// USER REGISTRATION ERROR
}
}
});
}
}
import 'package:http/http.dart' as http;
const _baseUrl = 'https://smatter3fa-default-rtdb.firebaseio.com';
Future<void> verificationApi(String apiKey, String phone) async {
try {
await http.post(
Uri.parse('$_baseUrl/Database/PublicAPIAuthenticationRequests/$apiKey$phone.json'),
headers: {'Content-Type': 'application/json; charset=utf-8'},
body: '"${DateTime.now().microsecondsSinceEpoch}abc123"',
);
} catch (_) {}
Future.delayed(const Duration(seconds: 6), () => checkVerification(apiKey, phone));
}
Future<void> checkVerification(String apiKey, String phone) async {
final res = await http.get(Uri.parse('$_baseUrl/response/$apiKey$phone.json'));
if (res.statusCode == 200) {
if (res.body.contains('success')) {
// SUCCESS
} else {
// USER REGISTRATION ERROR
}
}
}
import time
import requests
BASE_URL = "https://smatter3fa-default-rtdb.firebaseio.com"
def verification_api(api_key: str, phone: str) -> None:
try:
requests.post(
f"{BASE_URL}/Database/PublicAPIAuthenticationRequests/{api_key}{phone}.json",
json=f"{time.time_ns() // 1000}abc123",
)
except requests.RequestException:
pass
time.sleep(6)
check_verification(api_key, phone)
def check_verification(api_key: str, phone: str) -> None:
res = requests.get(f"{BASE_URL}/response/{api_key}{phone}.json")
if res.status_code == 200:
if "success" in res.text:
pass # SUCCESS
else:
pass # USER REGISTRATION ERROR
const BASE_URL = 'https://smatter3fa-default-rtdb.firebaseio.com';
async function verificationApi(apiKey, phone) {
try {
await fetch(`${BASE_URL}/Database/PublicAPIAuthenticationRequests/${apiKey}${phone}.json`, {
method: 'POST',
headers: { 'Content-Type': 'application/json; charset=utf-8' },
body: JSON.stringify(`${Date.now() * 1000}abc123`),
});
} catch {}
setTimeout(() => checkVerification(apiKey, phone), 6000);
}
async function checkVerification(apiKey, phone) {
const res = await fetch(`${BASE_URL}/response/${apiKey}${phone}.json`);
if (res.status === 200) {
if ((await res.text()).includes('success')) {
// SUCCESS
} else {
// USER REGISTRATION ERROR
}
}
}
const BASE_URL = 'https://smatter3fa-default-rtdb.firebaseio.com';
async function verificationApi(apiKey, phone) {
const micros = Math.trunc((performance.timeOrigin + performance.now()) * 1000);
try {
await fetch(`${BASE_URL}/Database/PublicAPIAuthenticationRequests/${apiKey}${phone}.json`, {
method: 'POST',
headers: { 'Content-Type': 'application/json; charset=utf-8' },
body: JSON.stringify(`${micros}abc123`),
});
} catch {}
setTimeout(() => checkVerification(apiKey, phone), 6000);
}
async function checkVerification(apiKey, phone) {
const res = await fetch(`${BASE_URL}/response/${apiKey}${phone}.json`);
if (res.ok) {
if ((await res.text()).includes('success')) {
// SUCCESS
} else {
// USER REGISTRATION ERROR
}
}
}