title: Automating gsutil commands
body: <p>I'm trying to automate some gsutils commands, but struggling to see where the authentication files are kept and how to re-use (if thats what happens).</p>
  
  <p>I've gone through the gcloud init process in bash...</p>
  
  <pre><code>curl https://sdk.cloud.google.com | bash
  gcloud init
  </code></pre>
  
  <p>All works well when I run </p>
  
  <pre><code>  'gsutil ls'
  </code></pre>
  
  <p>Now I'm trying to automate the process, so this would work on a new server adding into a crontab on it (rather than creating a new config each time). </p>
  
  <p>I saw a mention of setting env variable GOOGLE_APPLICATION_CREDENTIALS, so I copied my credentials from web login to a file and tried it, eg trying as a different user to test</p>
  
  <pre><code>export GOOGLE_APPLICATION_CREDENTIALS=/home/user/.gsutil/mycreds
  </code></pre>
  
  <p>and then gsutil ls, but fails.</p>
  
  <p>So I assume I've got the whole credentials thing a bit wrong. I'm assuming there is a file somewhere that was originally created by gcloud which I could use, but I can't see it anywhere ?</p>
  
  <p>I've looked at the answer <a href="https://stackoverflow.com/questions/15509368/is-it-possible-to-automate-gsutil-login">here</a> but doesn't seem up to date now, as per last comment.</p>
  
  <p><strong>Edit</strong>: I have followed Zacharys steps, gcloud auth activate-service-account --key-file=myfilelocation</p>
  
  <p>However, with 'gsutil ls' I now get..</p>
  
  <pre><code>You are attempting to perform an operation that requires a project id, with none configured. Please re-run gsutil config and make sure to follow the instructions for finding and entering your default project id.
  </code></pre>
  
  <p>So my next question would be, where is it looking for the project id ? If I run gsutil config, it seems to create a new set of auth which then creates another error, so have removed that.</p>