Skip to content

Instantly share code, notes, and snippets.

View hiranya911's full-sized avatar

Hiranya Jayathilaka hiranya911

View GitHub Profile
await fetch('https://api.myserver.com/quotes');
const express = require('express');
const admin = require('firebase-admin');
const app = express();
admin.initializeApp();
const appCheckVerification = async (req, res, next) => {
const appCheckToken = req.header('X-Firebase-AppCheck');
if (!appCheckToken) {
res.status(401);
return next('Unauthorized');
const { getToken } = require('firebase/app-check');
const appCheckTokenResponse = await getToken(appCheck);
await fetch('https://api.myserver.com/quotes', {
headers: {
'X-Firebase-AppCheck': appCheckTokenResponse.token,
}
});
const express = require('express');
const app = express();
app.get('/quotes', async (req, res) => {
const data = await callExternalService();
res.json(data);
});
// With App Check JS SDK included as:
// <script src="https://www.gstatic.com/firebasejs/9.0.0-beta.7/firebase-app-check-compat.js"></script>
const { initializeAppCheck, ReCaptchaV3Provider } = require("firebase/app-check");
const appCheck = initializeAppCheck(app, {
provider: new ReCaptchaV3Provider(siteKey),
isTokenAutoRefreshEnabled: true
});
import logging
import firebase_admin
from firebase_admin import messaging
def enable_urllib3_logging():
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
import firebase_admin
from firebase_admin import messaging
def enable_http_client_logging():
import http.client as http_client
http_client.HTTPConnection.debuglevel = 1
if __name__ == '__main__':
const admin = require('firebase-admin');
function enableRequestLogger() {
const https = require('https');
const original = https.request
https.request = function(options, callback){
console.log(`${new Date().toISOString()} ${options.method} ${options.protocol}//${options.hostname}${options.path}`);
return original(options, callback);
}
}
const admin = require('firebase-admin');
admin.initializeApp();
// Lookup user accounts by uid, email, phone number of IdP-assigned uid.
// List up to 100 identifiers to lookup.
const uids = [
{uid: 'sample-uid-1'},
{uid: 'sample-uid-2'},
{email: '[email protected]'},
const admin = require('firebase-admin');
// Usage: node delete_user.js <email>
const app = admin.initializeApp();
const email = process.argv[2];
admin.auth().getUserByEmail(email)
.then((user) => {
return admin.auth().deleteUser(user.uid);