json - gcloud auth activate-service-account [ERROR] Please ensure provided key file is valid -


i've spent several hours problem seems can't activate service account develop locally app engine project (if deploy teh project authenticates since credentials injected env variable).

the problem

  1. i created new service account under iam on gc platform.
    service account created correctly can see through console ,
  2. under service account generated new json key -> key.json

  3. in console used gcloud auth activate-service-account --key file=key.json

code

 {           "type": "service_account",     <br>      "project_id": "[project id]",     <br>      "private_key_id": "[private_key_id]",     <br>      "private_key": "[private_key]",     <br>      "client_email": "[name]",     <br>      "client_id": "[clien id]",     <br>      "auth_uri": "https://accounts.google.com/o/oauth2/auth",     <br>      "token_uri": "https://accounts.google.com/o/oauth2/token",     <br>      "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",         <br>  "client_x509_cert_url":        "https://www.googleapis.com/robot/v1/metadata/x509/[client_email]"        <br> }    

i receive error message error: (gcloud.auth.activate-service-account) failed activate given service account. please ensure provided key file valid.


after trying found in docs service account key indeed has different structure. https://cloud.google.com/iam/reference/rest/v1/projects.serviceaccounts.keys have no idea why downloaded key structure not good.

did encounter issue? solutions?

i haven't found great documentation on this, want first type of file , creating through cloud console should work. believe it's referenced google credentials file. downloaded json file should like:

{   "type": "service_account",   "project_id": "project-id",   "private_key_id": "some_number",   "private_key": "-----begin private key-----\n....   =\n-----end private key-----\n",   "client_email": "<api-name>api@project-id.iam.gserviceaccount.com",   "client_id": "...",   "auth_uri": "https://accounts.google.com/o/oauth2/auth",   "token_uri": "https://accounts.google.com/o/oauth2/token",   "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",   "client_x509_cert_url": "https://www.googleapis.com/...<api-name>api%40project-id.iam.gserviceaccount.com" } 

the second link posted create service account key , google credentials file, it's more work want (the google credentials file encoded under privatekeydata field.

hopefully explains files; luck authenticating! suggestion maybe you've spelled command wrong? should be:

gcloud auth activate-service-account --key-file=key.json 

whereas you've typed

gcloud auth activate-service-account --key file=key.json 

ie, space after --key. let know if figure out!


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -