This is part of the writeup on Using Google Cloud Storage with Apps Script. In Enabling APIs and OAuth2 I showed what needed to be done in the developer console to get credentials to use in your Script to access Cloud Storage. Now we'll move on to coding and how to use the service account from your script
You'll need the cGoa library, or some other library if you are using. It can be included in your project with this key
or the code is on github if you prefer.
The script properties are used to automatically renew oauth2 tokens when required, so the entire OAuth2 process is invisible to you. But first, you need to populate the script Properties by running a piece of code one time. You can delete it from your project once you've run it.
You need to make two changes to tailor it for you.
And that's all there is to it. Now you can delete this function and start using these credentials in your script, as described in GcsStore overview - Google Cloud Storage and Apps Script
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Google cloud topics > Cloud Storage and Apps Script >