title: gcloud auth activate-service-account [ERROR] Please ensure provided key file is valid
body: <p>I've spent already several hours with this problem but it seems that I can't activate a service account to develop locally an App Engine project (If I deploy teh project it authenticates well since the credentials are injected as an env variable).</p>
  <p><strong>The problem</strong></p>
  <ol>
  <li><p>I created a new service account under IAM on the GC Platform.
  <br> The service account is created correctly I can see it through the console and the</p>
  </li>
  <li><p>Under service account I generated a new JSON key -&gt; key.json</p>
  </li>
  <li><p>in the console I used
  gcloud auth activate-service-account --key file=key.json</p>
  </li>
  </ol>
  <h2>Code</h2>
  <pre><code> {    
        &quot;type&quot;: &quot;service_account&quot;,
      &lt;br&gt;      &quot;project_id&quot;: &quot;[project id]&quot;,
      &lt;br&gt;      &quot;private_key_id&quot;: &quot;[private_key_id]&quot;,
      &lt;br&gt;      &quot;private_key&quot;: &quot;[private_key]&quot;,
      &lt;br&gt;      &quot;client_email&quot;: &quot;[name]&quot;,
      &lt;br&gt;      &quot;client_id&quot;: &quot;[clien id]&quot;,
      &lt;br&gt;      &quot;auth_uri&quot;: &quot;https://accounts.google.com/o/oauth2/auth&quot;,
      &lt;br&gt;      &quot;token_uri&quot;: &quot;https://accounts.google.com/o/oauth2/token&quot;,
      &lt;br&gt;      &quot;auth_provider_x509_cert_url&quot;: &quot;https://www.googleapis.com/oauth2/v1/certs&quot;,
          &lt;br&gt;  &quot;client_x509_cert_url&quot;: 
        &quot;https://www.googleapis.com/robot/v1/metadata/x509/[client_email]&quot;
         &lt;br&gt; }   
  </code></pre>
  <p>I receive the error message <strong>ERROR: (gcloud.auth.activate-service-account) Failed to activate the given service account. Please ensure provided key file is valid.</strong></p>
  <hr />
  <p>After trying everything what I could I found that in the docs the service account key indeed has a different structure. <a href="https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts.keys" rel="noreferrer">https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts.keys</a>
  I have no idea however why the downloaded key structure is not good.</p>
  <p>Did anybody encounter this issue? Any solutions?</p>