Sure thing.
Here is the reference for Romain's Firebase Library:
https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebaseI create and store all the info in Firebase and use his library as the glue.
I use the Secret still and Firebase likes to try to get me to migrate telling me that it is legacy and deprecated, but that's how I roll :) (Plus that is all I know how to do :)
Access that from Settings->Service Accounts ->Database Secrets
A fun fact is that you can update to a nonexistent stem so I use update almost all the time (regardless of needing to check whether that stem exists).
It is a bit odd sharing code as nobody really ever looks at my code, so excuse any oddities. I am sure Romain and the other gurus here could improve upon it, but once I get my house of code cards standing I walk away so I don't knock them over :)
Relevant code snippet to get data from Firebase:
var user = Session.getEffectiveUser().getEmail();
//before we copy over the user, get the encodeAsFirebaseKey(user) to store in UserProperties
var firebaseEmail = encodeAsFirebaseKey(user);
var firebaseUrl = "
https://your-awesome-project.firebaseio.com/";
var secret = "mySuperLongDatabaseSecret";
//check if user is Premium and then store in userProperties
//can check/update path even if it doesn't exist yet
var database = FirebaseApp.getDatabaseByUrl(firebaseUrl, secret);
firebaseEmail = firebaseEmail.toLowerCase();
var emailParts = firebaseEmail.split('@');
var domain = emailParts[1];
Logger.log('domain: '+domain);
//check for domain premium license
var domainStemPremiumValue = database.getData("users/"+domain+"/premium");
Logger.log("domainStemPremiumValue: "+domainStemPremiumValue);
//set the UserId with the user
var userProperties = PropertiesService.getUserProperties();
userProperties.setProperty("userId", user);
userProperties.setProperty("userDomain", domain);
if(domainStemPremiumValue == "true"){
userProperties.setProperty('premiumUser','true');
}
Here is the encodeAsFirebaseKey function from Romain as well. There are a lot of shoutouts to Romain in my code comments :)
I also have a decodeAsFirebaseKey function that I use sometimes as well...
Hope that helps!
Cheers,
John