title: Google Analytics API fails to login with bad request and invalidKey
body: <p>I´m trying to get some data from analytics, but can´t get authorized. It returns the following error:</p>
  
  <p>I renewed my credentials at google console several times.</p>
  
  <p>The code I´m using:</p>
  
  <pre><code>var clientId = '*****************0m1fnmuae00abaaq.apps.googleusercontent.com';
  var apiKey = '********fB9eVMVfQ0oR6';
  var scopes = 'https://www.googleapis.com/auth/analytics.readonly';
  
  
  function handleClientLoad() {
    gapi.client.setApiKey(apiKey);
    window.setTimeout(checkAuth, 1);
  }
  
  
  function checkAuth() {
    gapi.auth.authorize({
      client_id: clientId, scope: scopes, immediate: true}, handleAuthResult);
  }
  
  
  function handleAuthResult(authResult) {
    if (authResult) {
      gapi.client.load('analytics', 'v3', handleAuthorized);
    } else {
      handleUnauthorized();
    }
  }
  
  
  function handleAuthorized() {
    var authorizeButton = document.getElementById('authorize-button');
    var runDemoButton = document.getElementById('run-demo-button');
  
    authorizeButton.style.visibility = 'hidden';
    runDemoButton.style.visibility = '';
    runDemoButton.onclick = makeApiCall;
    outputToPage('Click the Run Demo button to begin.');
  }
  
  
  function handleUnauthorized() {
    var authorizeButton = document.getElementById('authorize-button');
    var runDemoButton = document.getElementById('run-demo-button');
  
    runDemoButton.style.visibility = 'hidden';
    authorizeButton.style.visibility = '';
    authorizeButton.onclick = handleAuthClick;
    outputToPage('Please authorize this script to access Google Analytics.');
  }
  
  
  function handleAuthClick(event) {
    gapi.auth.authorize({
      client_id: clientId, scope: scopes, immediate: false}, handleAuthResult);
    return false;
  }
  </code></pre>
  
  <p>When I run the code, it returns the following error:</p>
  
  <pre><code>error: {errors:[{domain:usageLimits, reason:keyInvalid, message:Bad Request}], code:400, message:Bad Request}
  code: 400
  errors: [{domain:usageLimits, reason:keyInvalid, message:Bad Request}]
  0: {domain:usageLimits, reason:keyInvalid, message:Bad Request}
  domain: "usageLimits"
  message: "Bad Request"
  reason: "keyInvalid"
  message: "Bad Request"
  </code></pre>
  
  <p>Someone can help with this issue?</p>