title: Google Analytics API access without local browser in python
body: <p>I want to query the Google Analytics API using Python to periodically download data from my Analytics account and store data in a local database. I am basically following the steps as given in the <a href="https://developers.google.com/analytics/resources/tutorials/hello-analytics-api">basic tutorial</a>. I am using the <a href="https://code.google.com/p/google-api-python-client/">Google client API library for Python</a> in this process.</p>
  
  <p>My script is working fine so far when I am running it on my local dev machine (Mac). When I start the script, my browser opens and I am prompted to grant access to my Analytics data from the app. Afterwards I can run my script as often as I want and get access to my data. </p>
  
  <p>On my server (Ubuntu, only terminal available), the <code>w3m</code> browser opens, but I cannot access my Google account from there. I can only quit <code>w3m</code> and kill the program with <code>Ctrl-C</code>. There is an error message like:</p>
  
  <blockquote>
    <p>Your browser has been opened to visit:</p>
    
    <p><a href="https://accounts.google.com/o/oauth2/auth?scope=some_long_url&amp;access_type=offline">https://accounts.google.com/o/oauth2/auth?scope=some_long_url&amp;access_type=offline</a></p>
    
    <p>If your browser is on a different machine then exit and re-run this
    application with the command-line parameter </p>
    
    <p>--noauth_local_webserver</p>
  </blockquote>
  
  <p>However when I run my script with the parameter <code>--noauth_local_webserver</code>, I get the same results - <code>w3m</code> opens and I cannot authenticate.</p>
  
  <p>How can I get the <code>--noauth_local_webserver</code> to work? I there another way to authenticate without a local browser on the same machine?</p>