RomainVialard / Google-Plus-Community-Migrator

https://docs.google.com/document/d/1UGhxaN5AiRXXL0Ki0DlVWLYJo_YYiEYhM2w1caRhljU/edit
12 stars 5 forks source link

Is authentication required by passing token? #7

Closed brainysmurf closed 5 years ago

brainysmurf commented 5 years ago

These two lines:

var token = ScriptApp.getOAuthToken();
var fb = FirebaseApp.getDatabaseByUrl(firebaseBaseUrl, token);

Following the instructions, I have no authentication setup, and when the token is passed I get an authentication error from Firebase library. However, if I remove passing the token, it succeeds.

RomainVialard commented 5 years ago

You can find more info about this authentication method here: https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase/tutorials/authenticate-via-oauth-2-access-token

If you removed passing the token and it succeeded it means your database is freely accessible (anyone can read and write to it), which is not advised.

brainysmurf commented 5 years ago

I mean that the documentation has the database put in test mode, which does not need a token (and in fact fails if sent one), but then asks the user to run the script to populate the database. The Code.gs passes the token.

RomainVialard commented 5 years ago

I just changed to locked mode in the documentation. I don't think calls with the token should fail in test mode but test mode means a warning is displayed in Firebase UI, so better to switch to locked mode as it doesn't change anything and avoid the warning.

brainysmurf commented 5 years ago

Right I realize what I did: I was using two different accounts for the firebase database and where I was running the appscript, explaining why the token failed.