r/GoogleAppsScript • u/geminiikki • Apr 12 '25
Question What are the differences between Apps Script OAuth and Service Account?
Hi all,
I started coding with Google Apps Script and used Google Apps Script OAuth to connect to advanced services multiple times. A simple ScriptApp.getAuthToken() with permission on appsscript.json file allows me to retrieve Sheets API. On the other hand, I heard about setting up a service account could do the same, and I don't have to worry about 7-day reauthorization. I tried to search/AI but none give me useful information, so I just want to ask what are the differences between a service account and an Apps Script Oauth, and which should I use for automation workflow that require API connection?
View all comments
Show parent comment
1
u/geminiikki Apr 14 '25
I work with a website with form module that will collect and add users information to sheet:
Every time I run the script, it called my webapp url and grant me new oauth token that I can use it in Bearer token for api integration. What I want to ask is whether it is possible to use service account in this case. From what I read, I guess I can replace my_webapp_url with one-time service account call to achieve long-lived refresh token?