--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/dd150868-c8e0-4317-a243-f4cb35bc43efn%40googlegroups.com.
Service accounts, while applicable, are not the best fit for this use-case. They are better suited to situations where the service account acts as a proxy for multiple users. In your case, the service account is just mirroring one account, your own. So it seems like overkill.
Alan's Web-App to Web-App approach is viable. But it adds another layer of abstraction, where the two Web Apps have to communicate, so now you also have the overhead of managing two GAS Web Apps instead of just one.
Here's a solution that I think is a better fit. Its not without its own pros and cons, but its more succinct. Upfront, its more work to setup, but I feel it will be easier to maintain over time since you get to keep the business logic of your app in one place. Basically, you'll need to generate OAuth2 credentials specific to your account and use the OAuth2 library to generate access tokens. That access token can then be used to make direct calls against the Spreadsheet REST API OR alternatively, the Apps Script API (formerly the Execution API) to invoke a function in the script under your own authority.
Here's the basic sequence of steps involved:
From the GCP Cloud Console
From GAS project (direct invocation of REST API variant)
From GAS project (AppsScript/Execution API variant)
Once all the upfront setup is out of the way all you need to do is call either the Google Sheets REST API or the Apps Script API using UrlFetchApp.fetch() with the access tokens generated by the OAuth2 library. All from the same GAS project.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/028ab0cc-25f7-47b6-ad59-78fd97de8f70n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/daf3d5f0-31c2-41bd-b5ce-308cea1fad68n%40googlegroups.com.