title: Invalid credentials: Google API calendar
body: <p>I am new to using Google APIs. I followed steps to setup Google Calendar sample code in eclipse using Google client library. I deployed the code to app engine using the cmd command- mvn appengine:update (when tried to deploy through eclipse it gave me an error saying the project is not an App Engine project). Deploying through command line worked and I could launch my web application.</p>
  
  <p>Suddenly, after few API request calls, started getting invalid credentials error:</p>
  
  <blockquote>
    <p>error:401<br />
    domain:global<br />
    location: authorization<br />
    locationtype : header<br />
    message: invalid credentials<br />
    reason: auth error<br /></p>
  </blockquote>
  
  <p>I searched this error and found it may occur if your auth token is invalid or expired. I am not sure what I need to do to get a new auth token. In my case, there is a client_secrets.json file which has the client secrets. I did not put/save or use the auth token anywhere in the code. Following is what I remember when I deployed the code for the first time:</p>
  
  <ul>
  <li>There was some token which I was asked to paste on the cmd as I was deploying using the command line. After that I could launch my application. </li>
  <li>After that whenever I deployed my code and launched the application, there was no authorization(which happened the first time) and I could use the application and the API subsequently.</li>
  <li>Suddenly I started getting invalid credentials error. </li>
  </ul>
  
  <p>I was using client_secrets.json generated from the developer's console and I did not provide auth token anywhere in the code and I did not save it either. I read that a refresh token can be used and that can avoid expiration of the auth token.</p>
  
  <p>Currently, the issue is that I am getting invalid credentials error and I believe it is because of expiration of auth token. I am not aware about the solution in this case. It is the sample code provided by Google and I believe it automatically handles Oauth authorization (unlike the case where we programmatically call an Oauth url, get a token, store it somewhere and provide it with our subsequent requests). What do I need to do with the sample code so as to resolve this and not to run into the error in future? </p>
  
  <p>Also that the application is running fine locally, but the authorization issue comes when it is deployed on the cloud. Thanks.</p>