firebase-admin

how to write a query get Firestore current server time using firebase java admin sdk

▼魔方 西西 提交于 2019-12-11 08:48:25
问题 I want to write a query to get a list of document which was saved in the past 24 hours. When the document was created, I add a "last updated" value using FieldValue.serverTimestamp() . Now my query would be like: Date pastDay = (getFireStoreServerTime) - (24hours) Query query = collectionRef.orderBy("lastUpdated", Query.Direction.DESCENDING).where("last updated" > pastDay); However, I wasn't able to find the API in java admin SDK to get the server time. Is this supported in Firebase Admin SDK

Firebase Timestamp in cloud function not displaying time

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 08:14:25
问题 I am using this to get the timestamp admin.database.ServerValue.TIMESTAMP But in log getting this while doing console the variable { '.sv': 'timestamp' } anyone help me out in this. Actually i want to get the timestamp then compare it with db timestamp 回答1: The admin.database.ServerValue.TIMESTAMP does not contain the actual server-side timestamp, but is merely a marker (the { '.sv': 'timestamp' } that you see). The database server recognizes this marker on write operations, and then writes

REST api authentication using firebase admin sdk

大城市里の小女人 提交于 2019-12-11 05:12:20
问题 I have a REST api and the authentication is done using jwt tokens. To make may api more secure (users and authentication mechanism) I would like to use firebase authentication. I would like to know can we use firebase as a authentication server for my REST APIs. My understanding is that the client app will send the username and password to the firebase server and they will provide a token. Using that token client app will send an api call to our server. I need to integrate firebase admin SDK

Firebase logs out current user when creating a new one

强颜欢笑 提交于 2019-12-11 04:56:03
问题 I'm creating an iPhone app where an admin user can create new users, but as the Firebase documentation states "If the new account was created, the user is signed in automatically" , so I'm looking for a way to avoid signing in to that newly created user. Is there any way I can avoid this without using the new Firebase Admin SDK (that is web only AFAIK)? 回答1: You can solve this in multiple ways: Option 1 : save the credentials of the admin user securely on your device. Then, when the user

How to get the correct acces token for Firebase Dynamic Link Analytics Rest API (NodeJS)

喜欢而已 提交于 2019-12-11 04:26:26
问题 I have a problem with my access_token which I get with the serveracceskey. Here is my code in NodeJS: const admin = require('firebase-admin'); var request = require("request"); const serviceAccount = require('./serverAccountKey.json'); const credential = admin.credential.cert(serviceAccount); credential.getAccessToken().then((accessTokenInfo) => { const accessToken = accessTokenInfo.access_token; const expirationTime = accessTokenInfo.expires_in; console.log("accessToken " + accessToken );

Firebase admin sdk not syncing with the gradle

主宰稳场 提交于 2019-12-11 02:27:52
问题 I have incorporated some libraries into my android app. I have connected it with Firebase cloud server. Now, I want to create tokens for User authentication. Firebase asks to add Firebase Admin Sdk to the gradle File. However, it shows error on building the gradle. The sdk I am adding is compile 'com.google.firebase:firebase-admin:5.3.1' Following is the error: Error:Conflict with dependency 'com.google.code.findbugs:jsr305' in project ':app'. Resolved versions for app (3.0.0) and test app (2

Firebase Admin SDK: Set / Merge Custom User Claims

巧了我就是萌 提交于 2019-12-10 23:54:55
问题 Does Firebase have any trick like { merge: true } to set extra/more custom claims without delete/override the old variables? Step to reproduce: admin.auth().setCustomUserClaims(uid, { a: 'value' }) // Run this first admin.auth().setCustomUserClaims(uid, { b: 'value' }) // Then run this after Result: { b: 'value'} Expected result : { a: 'value', b: 'value' } Or I did something wrong? 回答1: The Firebase documentation for setCustomUserClaims states: customUserClaims : Object The developer claims

Detected an object of type “Timestamp” that doesn't match the expected instance

帅比萌擦擦* 提交于 2019-12-10 20:36:30
问题 I'm wondering why is the Timestamp object is not working as I expect? It works in test environment (I use Mocha), but throws error when it has been deployed. index.ts import { Timestamp, QuerySnapshot } from "@google-cloud/firestore"; .... async someFunction() { let col = firestore.collection("mycollection"); let now = Timestamp.now(); let twentyMinsAgo = Timestamp.fromMillis(now.toMillis() - (1200 * 1000)); return col .where('LastEdited', '>=', twentyMinsAgo) //This throws error .get() }

Python Firebase issue No module named firebase_admin

狂风中的少年 提交于 2019-12-10 18:29:17
问题 I have deployed a python code in Google App Engine.In my code,tried to import firebase_admin,but it shows following error, import firebase_admin ImportError: No module named firebase_admin hello.py import firebase_admin from firebase_admin import credentials from firebase_admin import db I tried simple python code using Terminal: hello.py import firebase_admin print firebase_admin Output in terminal: ~/Desktop$ python hello.py <module 'firebase_admin' from '/usr/local/lib/python2.7/dist

Firebase Authentication vs Firebase Admin

若如初见. 提交于 2019-12-10 16:49:35
问题 what is the difference between firebase authentication and firebase admin? As far as I know, firebase admin has authentication features and it can bypass security, unlike firebase authentication. And firebase admin is implemented in server-side while firebase authentication is mostly at the client side. I want to know why firebase authentication should be at client side and why we should use firebase authentication instead of firebase admin for authentication feature. 回答1: Firebase