If you want to do authenticated calls to Firebase or to Cloudfunctions that would need a token that is created on the client,
this is a way you can fetch the token (Firebase idToken) from your OAuthToken from Apps Script.
This is handy in many cases where the script is run as the user (like container bound).
1) Add firebase scope to manifest
2) Use this code to fetch the idToken
3) Make sure the apps script is bound to the firebase project (<-- yes, this was the main key)
function getFBIdToken() {
var token = ScriptApp.getOAuthToken();
var url = "https://identitytoolkit.googleapis.com/v1/accounts:signInWithIdp?key=[FIREBASE KEY]"
var data = {"postBody":"access_token="+token+"&providerId=google.com","requestUri":"https://[firebaseproject].firebaseapp.com","returnIdpCredential":true,"returnSecureToken":true};
var options = {
method: "POST",
payload: JSON.stringify(data),
muteHttpExceptions: true,
contentType: 'application/json'
}
var data = JSON.parse(UrlFetchApp.fetch(url,options).getContentText());
return data.idToken;
}
Enjoy!