firebase / functions-samples

Collection of sample apps showcasing popular use cases using Cloud Functions for Firebase
https://firebase.google.com/docs/functions
Apache License 2.0
12.03k stars 3.83k forks source link

Possible outdated Cloud Function URLs in google-sheet-sync sample #446

Open wyeager opened 6 years ago

wyeager commented 6 years ago

Sample name or URL where you found the bug google-sheet-sync

Failing Function code used (including require/import commands at the top) line 50 of index.js authgoogleapi also steps 6, 12 and 13 of the readme

Steps to set up and reproduce follow all instructions of the readme on step 12 when I go to https://{YOUR-PROJET-ID}.firebaseapp.com/authgoogleapi I get a 404

Expected behavior

going to https://{YOUR-PROJET-ID}.firebaseapp.com/authgoogleapi should set an access token used for writing to Google Sheets

Actual behavior

instead it gives me a 404

I think the issue is that Firebase has changed the URLs where they host Cloud Functions. After I changed line 36 of index.js to: const FUNCTIONS_REDIRECT = 'https://us-central1-${process.env.GCLOUD_PROJECT}.cloudfunctions.net/oauthcallback'; and updated my authorized redirect URI in the Google APIs console everything worked.

Similarly, steps 12 and 13 should be to visit: https://us-central1-{YOUR-PROJET-ID}.cloudfunctions.net/authgoogleapi https://us-central1-{YOUR-PROJET-ID}.cloudfunctions.net/testsheetwrite

Maybe I've configured things incorrectly and the readme is correct, but just thought I'd point this out in case it is a bug.

darthink commented 5 years ago

I can confirm, I had to change to us-central1- and cloudfunctions.net.

samtstern commented 5 years ago

The firebaseapp.com domains come from the hosting rewrite config: https://github.com/firebase/functions-samples/blob/Node-8/google-sheet-sync/firebase.json#L5

Did you do a full firebase deploy that includes hosting? If you only deployed functions you'd get the error described