How to integrate Firebase into Google Apps Script without using (deprecated) database secret









up vote
2
down vote

favorite












For a while ago I was using integration of Firebase in Google Apps Script as a server side and it was working finely and still working in my old projects.



But today after creating a new Firebase project and a new realtime database then trying to integrate Firebase Project into my Google Script project I got an error and it's not working completely. And I realize that Firebase deprecated database secret for new projects.



So, my question now is how to come over this problem? Is there another way to integrate Firebase into Google Script project?










share|improve this question



























    up vote
    2
    down vote

    favorite












    For a while ago I was using integration of Firebase in Google Apps Script as a server side and it was working finely and still working in my old projects.



    But today after creating a new Firebase project and a new realtime database then trying to integrate Firebase Project into my Google Script project I got an error and it's not working completely. And I realize that Firebase deprecated database secret for new projects.



    So, my question now is how to come over this problem? Is there another way to integrate Firebase into Google Script project?










    share|improve this question

























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      For a while ago I was using integration of Firebase in Google Apps Script as a server side and it was working finely and still working in my old projects.



      But today after creating a new Firebase project and a new realtime database then trying to integrate Firebase Project into my Google Script project I got an error and it's not working completely. And I realize that Firebase deprecated database secret for new projects.



      So, my question now is how to come over this problem? Is there another way to integrate Firebase into Google Script project?










      share|improve this question















      For a while ago I was using integration of Firebase in Google Apps Script as a server side and it was working finely and still working in my old projects.



      But today after creating a new Firebase project and a new realtime database then trying to integrate Firebase Project into my Google Script project I got an error and it's not working completely. And I realize that Firebase deprecated database secret for new projects.



      So, my question now is how to come over this problem? Is there another way to integrate Firebase into Google Script project?







      firebase firebase-realtime-database google-apps-script






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 8 at 14:23









      Frank van Puffelen

      218k25361386




      218k25361386










      asked Nov 8 at 12:38









      Muhammad Saleh

      30529




      30529






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          You'll need to add the correct OAuth scopes to the manifest file of your Apps Script project, and then pass in an access_token parameter (or in the Authorization header) instead of the auth parameter you currently use.



          Based on Doug's gist here, the basic steps are:



          1. Open the manifest.json from the script editor, by clicking View > Show manifest file.


          2. Add or edit the manifest to have these OAuth scopes:



            "oauthScopes": [
            "https://www.googleapis.com/auth/userinfo.email",
            "https://www.googleapis.com/auth/firebase.database",
            "https://www.googleapis.com/auth/script.external_request",
            "https://www.googleapis.com/auth/spreadsheets"
            ]


            That last scope grants it access to the spreadsheet itself. If you're using another GSuite type (document, slides, form, etc) you'll need the scope that corresponds that to type.




          3. Now you can get the OAuth token from within your script and add it to your request:



            var response = UrlFetchApp.fetch(databaseUrl, 
            method: "PUT",
            headers:
            "Content-type": "application/json",
            "Authorization": "Bearer "+ScriptApp.getOAuthToken()
            ,
            payload: JSON.stringify(json)
            );
            Logger.log(response.getContentText());


          A major advantage of this is that your script will now run as an actual user, meaning that you can ensure it can only perform authorized actions through security rules.






          share|improve this answer






















          • Thank You Frank!. I really appreciate your help.
            – Muhammad Saleh
            Nov 9 at 8:23










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53207906%2fhow-to-integrate-firebase-into-google-apps-script-without-using-deprecated-dat%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          You'll need to add the correct OAuth scopes to the manifest file of your Apps Script project, and then pass in an access_token parameter (or in the Authorization header) instead of the auth parameter you currently use.



          Based on Doug's gist here, the basic steps are:



          1. Open the manifest.json from the script editor, by clicking View > Show manifest file.


          2. Add or edit the manifest to have these OAuth scopes:



            "oauthScopes": [
            "https://www.googleapis.com/auth/userinfo.email",
            "https://www.googleapis.com/auth/firebase.database",
            "https://www.googleapis.com/auth/script.external_request",
            "https://www.googleapis.com/auth/spreadsheets"
            ]


            That last scope grants it access to the spreadsheet itself. If you're using another GSuite type (document, slides, form, etc) you'll need the scope that corresponds that to type.




          3. Now you can get the OAuth token from within your script and add it to your request:



            var response = UrlFetchApp.fetch(databaseUrl, 
            method: "PUT",
            headers:
            "Content-type": "application/json",
            "Authorization": "Bearer "+ScriptApp.getOAuthToken()
            ,
            payload: JSON.stringify(json)
            );
            Logger.log(response.getContentText());


          A major advantage of this is that your script will now run as an actual user, meaning that you can ensure it can only perform authorized actions through security rules.






          share|improve this answer






















          • Thank You Frank!. I really appreciate your help.
            – Muhammad Saleh
            Nov 9 at 8:23














          up vote
          1
          down vote



          accepted










          You'll need to add the correct OAuth scopes to the manifest file of your Apps Script project, and then pass in an access_token parameter (or in the Authorization header) instead of the auth parameter you currently use.



          Based on Doug's gist here, the basic steps are:



          1. Open the manifest.json from the script editor, by clicking View > Show manifest file.


          2. Add or edit the manifest to have these OAuth scopes:



            "oauthScopes": [
            "https://www.googleapis.com/auth/userinfo.email",
            "https://www.googleapis.com/auth/firebase.database",
            "https://www.googleapis.com/auth/script.external_request",
            "https://www.googleapis.com/auth/spreadsheets"
            ]


            That last scope grants it access to the spreadsheet itself. If you're using another GSuite type (document, slides, form, etc) you'll need the scope that corresponds that to type.




          3. Now you can get the OAuth token from within your script and add it to your request:



            var response = UrlFetchApp.fetch(databaseUrl, 
            method: "PUT",
            headers:
            "Content-type": "application/json",
            "Authorization": "Bearer "+ScriptApp.getOAuthToken()
            ,
            payload: JSON.stringify(json)
            );
            Logger.log(response.getContentText());


          A major advantage of this is that your script will now run as an actual user, meaning that you can ensure it can only perform authorized actions through security rules.






          share|improve this answer






















          • Thank You Frank!. I really appreciate your help.
            – Muhammad Saleh
            Nov 9 at 8:23












          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          You'll need to add the correct OAuth scopes to the manifest file of your Apps Script project, and then pass in an access_token parameter (or in the Authorization header) instead of the auth parameter you currently use.



          Based on Doug's gist here, the basic steps are:



          1. Open the manifest.json from the script editor, by clicking View > Show manifest file.


          2. Add or edit the manifest to have these OAuth scopes:



            "oauthScopes": [
            "https://www.googleapis.com/auth/userinfo.email",
            "https://www.googleapis.com/auth/firebase.database",
            "https://www.googleapis.com/auth/script.external_request",
            "https://www.googleapis.com/auth/spreadsheets"
            ]


            That last scope grants it access to the spreadsheet itself. If you're using another GSuite type (document, slides, form, etc) you'll need the scope that corresponds that to type.




          3. Now you can get the OAuth token from within your script and add it to your request:



            var response = UrlFetchApp.fetch(databaseUrl, 
            method: "PUT",
            headers:
            "Content-type": "application/json",
            "Authorization": "Bearer "+ScriptApp.getOAuthToken()
            ,
            payload: JSON.stringify(json)
            );
            Logger.log(response.getContentText());


          A major advantage of this is that your script will now run as an actual user, meaning that you can ensure it can only perform authorized actions through security rules.






          share|improve this answer














          You'll need to add the correct OAuth scopes to the manifest file of your Apps Script project, and then pass in an access_token parameter (or in the Authorization header) instead of the auth parameter you currently use.



          Based on Doug's gist here, the basic steps are:



          1. Open the manifest.json from the script editor, by clicking View > Show manifest file.


          2. Add or edit the manifest to have these OAuth scopes:



            "oauthScopes": [
            "https://www.googleapis.com/auth/userinfo.email",
            "https://www.googleapis.com/auth/firebase.database",
            "https://www.googleapis.com/auth/script.external_request",
            "https://www.googleapis.com/auth/spreadsheets"
            ]


            That last scope grants it access to the spreadsheet itself. If you're using another GSuite type (document, slides, form, etc) you'll need the scope that corresponds that to type.




          3. Now you can get the OAuth token from within your script and add it to your request:



            var response = UrlFetchApp.fetch(databaseUrl, 
            method: "PUT",
            headers:
            "Content-type": "application/json",
            "Authorization": "Bearer "+ScriptApp.getOAuthToken()
            ,
            payload: JSON.stringify(json)
            );
            Logger.log(response.getContentText());


          A major advantage of this is that your script will now run as an actual user, meaning that you can ensure it can only perform authorized actions through security rules.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 8 at 19:21

























          answered Nov 8 at 16:15









          Frank van Puffelen

          218k25361386




          218k25361386











          • Thank You Frank!. I really appreciate your help.
            – Muhammad Saleh
            Nov 9 at 8:23
















          • Thank You Frank!. I really appreciate your help.
            – Muhammad Saleh
            Nov 9 at 8:23















          Thank You Frank!. I really appreciate your help.
          – Muhammad Saleh
          Nov 9 at 8:23




          Thank You Frank!. I really appreciate your help.
          – Muhammad Saleh
          Nov 9 at 8:23

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53207906%2fhow-to-integrate-firebase-into-google-apps-script-without-using-deprecated-dat%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

          ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

          Node.js puppeteer - Use values from array in a loop to cycle through pages