How to custom claims token to firebase firestore rules via Android App?

40
October 09, 2019, at 2:10 PM

I'm trying to customize claims token to firestore rule via Cloud Functions but it do not appear a good solution because it throws an exception when I try create an user via Android Application like follow:

Caused by: io.grpc.StatusException: PERMISSION_DENIED: Missing or insufficient permissions.

I'm trying intercept the user creation by follow cloud function:

const functions = require('firebase-functions'); 
const admin = require('firebase-admin'); 
admin.initializeApp();
exports.addAdminRole = functions.firestore
    .document("users/{user}")
    .onWrite((change, ctx) => {
        return admin.auth().setCustomUserClaims(ctx.auth.uid, {
            role: "ADMIN"
        })
});

Below it's the token customization working via SIMULATOR!

What I need to do it?

READ ALSO
Cordova ble.write i can't send data (Android)

Cordova ble.write i can't send data (Android)

this function writes data to a characteristic

13
Using ScheduledExecutorService to start and stop ToneGenerator linked to timer

Using ScheduledExecutorService to start and stop ToneGenerator linked to timer

I'm using ScheduledExecutorService to play a tone every 2 seconds that a CountDownTimer is runningWhen the CountDownTimer is paused or reset, I need the tone to stop playing

26
Toolbar overflow menu sometimes aligned to left side of screen

Toolbar overflow menu sometimes aligned to left side of screen

My app has multiple Fragments and a custom Toolbar, on the MainActivityThe toolbar is inflated on my 1st fragment but not the other fragments

41
Interactive model (graphic)

Interactive model (graphic)

I would like to develop an interactive model of a neuronThe neuron needs to display information (or whatever) when a part is clicked on it

18