title: Running from Cron Python/ Google API will not accept stored Credentials file but from command line it will
body: <p>So I had what I thought was a functioning Python script which would access a stored Google Oauth Credentials file.</p>
  
  <p>When I run:</p>
  
  <pre><code>source /METRICS/VIRTUALENVS/google/venv/bin/activate; export LD_LIBRARY_PATH='/usr/lib/oracle/11.2/client64/lib'; /METRICS/GOOGLESTATS/get_report_2.py
  </code></pre>
  
  <p>it works famously.</p>
  
  <p>In the python there is a block which check the credentials from a stored file:</p>
  
  <pre><code>#get google storage object
  storage = Storage('cred_storage.txt')
  credentials = storage.get()
  
  #check if credentials are valid If not send to web page for new key.
  if not credentials:
      flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, REDIRECT_URI)
      authorize_url = flow.step1_get_authorize_url()
      print 'Go to the following link in your browser: ' + authorize_url
      code = raw_input('Enter verification code: ').strip()
      credentials = flow.step2_exchange(code)
      storage.put(credentials)
      mysendmail('Re authentication of credentials necessary')
      exit()
  </code></pre>
  
  <p>All is good however if I run the same thing from my local user crontab the credentials fail as if the Credentials file is unreadable. </p>
  
  <p>I'm stumped as to why the difference from running the command from CRON vs the command line.</p>
  
  <p>Just for information I get the "go to URL" message back when the credentials fail to be read.</p>
  
  <p>My permissions on the credentials file is 0755 with the owner being the user of the local crontab. </p>
  
  <p>Thanks</p>