Set Ag-Grid License key using REST call












1















I am evaluating an enterprise license version of Ag-Grid in my Angular application. As per official document, it is suggested to use LicenseManager.setLicenseKey('my key') inside main.ts file before Angular bootstrap. I follow the procedure and I am able to launch the grid without any error.



Problem starts, when I don't want to commit my key inside the public github repository. Hence, I am getting it from my live server, by putting it manually there in system variable and accessing it by REST call (using crypto-js encryption). Now, if I have to get the key from REST call, I need to make a XMLHttpRequest before Angular bootstrap and I have to make sure angular bootstrap logic goes inside the success and failure of that REST call.



Now, these looks not good for me at all as:




  • There will be an extra network latency for my application to start

  • Bootstrap dependency on REST call.

  • Using XMLHttpRequest instead of Angular's HttpClient.


Is there any good way to setup this license key ? Can I set it during ng build --myCustomConfiguration_LicenseKey='XYZ', which I can pass it from build tool (Teamcity) ?



Note:




  • I tried making a REST call inside AppComponent or XMLHttpRequest call
    in bootstrap success method but still I am getting error in console
    that I am not using license version of the app. If I hard-code it ,
    it works fine.

  • I am forced not to use git-secret or any other library.










share|improve this question





























    1















    I am evaluating an enterprise license version of Ag-Grid in my Angular application. As per official document, it is suggested to use LicenseManager.setLicenseKey('my key') inside main.ts file before Angular bootstrap. I follow the procedure and I am able to launch the grid without any error.



    Problem starts, when I don't want to commit my key inside the public github repository. Hence, I am getting it from my live server, by putting it manually there in system variable and accessing it by REST call (using crypto-js encryption). Now, if I have to get the key from REST call, I need to make a XMLHttpRequest before Angular bootstrap and I have to make sure angular bootstrap logic goes inside the success and failure of that REST call.



    Now, these looks not good for me at all as:




    • There will be an extra network latency for my application to start

    • Bootstrap dependency on REST call.

    • Using XMLHttpRequest instead of Angular's HttpClient.


    Is there any good way to setup this license key ? Can I set it during ng build --myCustomConfiguration_LicenseKey='XYZ', which I can pass it from build tool (Teamcity) ?



    Note:




    • I tried making a REST call inside AppComponent or XMLHttpRequest call
      in bootstrap success method but still I am getting error in console
      that I am not using license version of the app. If I hard-code it ,
      it works fine.

    • I am forced not to use git-secret or any other library.










    share|improve this question



























      1












      1








      1








      I am evaluating an enterprise license version of Ag-Grid in my Angular application. As per official document, it is suggested to use LicenseManager.setLicenseKey('my key') inside main.ts file before Angular bootstrap. I follow the procedure and I am able to launch the grid without any error.



      Problem starts, when I don't want to commit my key inside the public github repository. Hence, I am getting it from my live server, by putting it manually there in system variable and accessing it by REST call (using crypto-js encryption). Now, if I have to get the key from REST call, I need to make a XMLHttpRequest before Angular bootstrap and I have to make sure angular bootstrap logic goes inside the success and failure of that REST call.



      Now, these looks not good for me at all as:




      • There will be an extra network latency for my application to start

      • Bootstrap dependency on REST call.

      • Using XMLHttpRequest instead of Angular's HttpClient.


      Is there any good way to setup this license key ? Can I set it during ng build --myCustomConfiguration_LicenseKey='XYZ', which I can pass it from build tool (Teamcity) ?



      Note:




      • I tried making a REST call inside AppComponent or XMLHttpRequest call
        in bootstrap success method but still I am getting error in console
        that I am not using license version of the app. If I hard-code it ,
        it works fine.

      • I am forced not to use git-secret or any other library.










      share|improve this question
















      I am evaluating an enterprise license version of Ag-Grid in my Angular application. As per official document, it is suggested to use LicenseManager.setLicenseKey('my key') inside main.ts file before Angular bootstrap. I follow the procedure and I am able to launch the grid without any error.



      Problem starts, when I don't want to commit my key inside the public github repository. Hence, I am getting it from my live server, by putting it manually there in system variable and accessing it by REST call (using crypto-js encryption). Now, if I have to get the key from REST call, I need to make a XMLHttpRequest before Angular bootstrap and I have to make sure angular bootstrap logic goes inside the success and failure of that REST call.



      Now, these looks not good for me at all as:




      • There will be an extra network latency for my application to start

      • Bootstrap dependency on REST call.

      • Using XMLHttpRequest instead of Angular's HttpClient.


      Is there any good way to setup this license key ? Can I set it during ng build --myCustomConfiguration_LicenseKey='XYZ', which I can pass it from build tool (Teamcity) ?



      Note:




      • I tried making a REST call inside AppComponent or XMLHttpRequest call
        in bootstrap success method but still I am getting error in console
        that I am not using license version of the app. If I hard-code it ,
        it works fine.

      • I am forced not to use git-secret or any other library.







      angular ag-grid






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 25 '18 at 18:18







      Amit sharma

















      asked Nov 25 '18 at 17:48









      Amit sharmaAmit sharma

      64




      64
























          1 Answer
          1






          active

          oldest

          votes


















          0















          Is there any good way to setup this license key ? Can I set it during ng build --myCustomConfiguration_LicenseKey='XYZ', which I can pass it from build tool (Teamcity) ?




          Yes - without using REST call.



          Once you do ng build --prod, the LicenseManager.setLicenseKey('#my_key#') part of your code goes into main.<randomString>.js file of the generated output.



          You can have one powershell script (or shell script) which replaces #my_key# with your actual license key.



          OR




          1. In your CI, once you get the latest code, replace #my_key# with your actual license key in main.ts file with powershell (or shell) script. Add this step to your CI.


          2. Trigger ng build --prod







          share|improve this answer
























          • Thanks Paritosh for your response , but in this case my key will be visible to my browser source code clearly, even though I do a production minified build.

            – Amit sharma
            Nov 26 '18 at 8:53











          • That's right if you don't want that. Anyways, will keep the answer - perhaps it'll be helpful to someone else.

            – Paritosh
            Nov 26 '18 at 9:32











          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',
          autoActivateHeartbeat: false,
          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%2f53470224%2fset-ag-grid-license-key-using-rest-call%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









          0















          Is there any good way to setup this license key ? Can I set it during ng build --myCustomConfiguration_LicenseKey='XYZ', which I can pass it from build tool (Teamcity) ?




          Yes - without using REST call.



          Once you do ng build --prod, the LicenseManager.setLicenseKey('#my_key#') part of your code goes into main.<randomString>.js file of the generated output.



          You can have one powershell script (or shell script) which replaces #my_key# with your actual license key.



          OR




          1. In your CI, once you get the latest code, replace #my_key# with your actual license key in main.ts file with powershell (or shell) script. Add this step to your CI.


          2. Trigger ng build --prod







          share|improve this answer
























          • Thanks Paritosh for your response , but in this case my key will be visible to my browser source code clearly, even though I do a production minified build.

            – Amit sharma
            Nov 26 '18 at 8:53











          • That's right if you don't want that. Anyways, will keep the answer - perhaps it'll be helpful to someone else.

            – Paritosh
            Nov 26 '18 at 9:32
















          0















          Is there any good way to setup this license key ? Can I set it during ng build --myCustomConfiguration_LicenseKey='XYZ', which I can pass it from build tool (Teamcity) ?




          Yes - without using REST call.



          Once you do ng build --prod, the LicenseManager.setLicenseKey('#my_key#') part of your code goes into main.<randomString>.js file of the generated output.



          You can have one powershell script (or shell script) which replaces #my_key# with your actual license key.



          OR




          1. In your CI, once you get the latest code, replace #my_key# with your actual license key in main.ts file with powershell (or shell) script. Add this step to your CI.


          2. Trigger ng build --prod







          share|improve this answer
























          • Thanks Paritosh for your response , but in this case my key will be visible to my browser source code clearly, even though I do a production minified build.

            – Amit sharma
            Nov 26 '18 at 8:53











          • That's right if you don't want that. Anyways, will keep the answer - perhaps it'll be helpful to someone else.

            – Paritosh
            Nov 26 '18 at 9:32














          0












          0








          0








          Is there any good way to setup this license key ? Can I set it during ng build --myCustomConfiguration_LicenseKey='XYZ', which I can pass it from build tool (Teamcity) ?




          Yes - without using REST call.



          Once you do ng build --prod, the LicenseManager.setLicenseKey('#my_key#') part of your code goes into main.<randomString>.js file of the generated output.



          You can have one powershell script (or shell script) which replaces #my_key# with your actual license key.



          OR




          1. In your CI, once you get the latest code, replace #my_key# with your actual license key in main.ts file with powershell (or shell) script. Add this step to your CI.


          2. Trigger ng build --prod







          share|improve this answer














          Is there any good way to setup this license key ? Can I set it during ng build --myCustomConfiguration_LicenseKey='XYZ', which I can pass it from build tool (Teamcity) ?




          Yes - without using REST call.



          Once you do ng build --prod, the LicenseManager.setLicenseKey('#my_key#') part of your code goes into main.<randomString>.js file of the generated output.



          You can have one powershell script (or shell script) which replaces #my_key# with your actual license key.



          OR




          1. In your CI, once you get the latest code, replace #my_key# with your actual license key in main.ts file with powershell (or shell) script. Add this step to your CI.


          2. Trigger ng build --prod








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 5:52









          ParitoshParitosh

          5,31142943




          5,31142943













          • Thanks Paritosh for your response , but in this case my key will be visible to my browser source code clearly, even though I do a production minified build.

            – Amit sharma
            Nov 26 '18 at 8:53











          • That's right if you don't want that. Anyways, will keep the answer - perhaps it'll be helpful to someone else.

            – Paritosh
            Nov 26 '18 at 9:32



















          • Thanks Paritosh for your response , but in this case my key will be visible to my browser source code clearly, even though I do a production minified build.

            – Amit sharma
            Nov 26 '18 at 8:53











          • That's right if you don't want that. Anyways, will keep the answer - perhaps it'll be helpful to someone else.

            – Paritosh
            Nov 26 '18 at 9:32

















          Thanks Paritosh for your response , but in this case my key will be visible to my browser source code clearly, even though I do a production minified build.

          – Amit sharma
          Nov 26 '18 at 8:53





          Thanks Paritosh for your response , but in this case my key will be visible to my browser source code clearly, even though I do a production minified build.

          – Amit sharma
          Nov 26 '18 at 8:53













          That's right if you don't want that. Anyways, will keep the answer - perhaps it'll be helpful to someone else.

          – Paritosh
          Nov 26 '18 at 9:32





          That's right if you don't want that. Anyways, will keep the answer - perhaps it'll be helpful to someone else.

          – Paritosh
          Nov 26 '18 at 9:32


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53470224%2fset-ag-grid-license-key-using-rest-call%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

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)