title: Why do I get "Invalid token" unless I invert projectId and clientId?
body: <p>In order to setup Google Identity Toolkit for my Website I started with the <a href="https://developers.google.com/identity/toolkit/web/quickstart/nodejs" rel="nofollow noreferrer">Quick-start App for Node.js</a>.</p>
  
  <p>It worked fine on localhost.
  But when I moved it to an actual app-engine instance it did not work anymore.
  I got this error returned by gitkitClient.verifyGitkitToken():</p>
  
  <blockquote>
    <p>Invalid token: Unable to verify the ID Token: Wrong recipient, payload
    audience != requiredAudience</p>
  </blockquote>
  
  <p>I found <a href="https://stackoverflow.com/questions/34948889/gitkit-java-client-library-trouble-verifying-token-signature-invalid-audience/34962116#34962116">a very helpful post on stackoverflow about more or less the same issue</a>, for Java instead of node.js: It looks like there is a mismatch between projectId and clientId.</p>
  
  <p>I changed my gitkit-server-config.json file to swap the <strong>projectId</strong> and <strong>clientId</strong> values and it worked!</p>
  
  <ul>
  <li>This sound very much like a major bug on google side, doesn't it?</li>
  <li>Why does it work on localhost?</li>
  <li>Will this be changed/fixed in the future?</li>
  <li>Maybe the problem is in the tutorial?</li>
  </ul>
  
  <p>I have a working solution for now, but I do not feel safe to keep it like that...</p>
  
  <p>I hope a googler will read this!</p>
  
  <p>[EDIT]</p>
  
  <p>Following wyhao31's comment I had a closer look at the <a href="https://github.com/google/identity-toolkit-node-client/blob/master/lib/gitkitclient.js" rel="nofollow noreferrer">gitkitclient.js source code</a> and both <strong>projectId</strong> and <strong>clientId</strong> are added to the same <strong>audiences</strong> array.
  After more test I found out that you must only put the project ID ('my-project-name') in the gitkit-server-config.json file.
  The nasty thing is that if you add it with a 'clientId' property name it is also working...</p>