App-check from firebase function

656 views
Skip to first unread message

Alex Whittaker

unread,
Jul 15, 2021, 7:35:52 AM7/15/21
to Firebase Google Group
Morning folks, before I submit a bug I just want to check that I'm not missing something - I have a cloud function that should be writing to the real time database, the database is protected with App Check which is failing to recognise the function servers as legitimate a endpoint. I am getting this error:

[2021-07-15T10:37:23.448Z] @firebase/database: FIREBASE WARNING: Missing appcheck token (https://xxxxxxxxxxxx-rtdb.europe-west1.firebasedatabase.app/)

If I turn off app-check on the database everything works as expected.


  ..alex

Sam Stern

unread,
Jul 15, 2021, 7:47:51 AM7/15/21
to fireba...@googlegroups.com
Hey Alex,

Are you using "firebase-admin" to write to the database or are you using the "firebase" package (which is the Web SDK). They both actually share a common JS core but they authenticate differently, which I think could be the difference here.

- Sam

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/b07bc67d-11b9-4e7c-82b0-0d26340e96a4n%40googlegroups.com.

Alex Whittaker

unread,
Jul 15, 2021, 8:50:39 AM7/15/21
to Firebase Google Group
Hi Sam, firebase-admin.

Alex Whittaker

unread,
Jul 15, 2021, 8:50:44 AM7/15/21
to Firebase Google Group
Function is here:

const admin = require('firebase-admin');
const handleException = require('../handleException');

module.exports = (data, context) => {

admin.database().ref(`userInvites/${context.auth.uid}/${data.inviteKey}`).set({
email: data.email,
invited: Date.now()
}).catch(handleException);
return true;
};

On Thursday, 15 July 2021 at 12:47:51 UTC+1 sams...@google.com wrote:

Sam Stern

unread,
Jul 15, 2021, 1:06:00 PM7/15/21
to fireba...@googlegroups.com
Hey Alex,

Apparently this is a known issue and should be addressed by this PR:
https://github.com/firebase/firebase-js-sdk/pull/5146

So the fix should be included in the next release of firebase-js-sdk (which will be pulled in by firebase-admin). You may need to update your package.json and package-lock.json after the fix rolls out.

- Sam

Reply all
Reply to author
Forward
0 new messages