title: How to use Google Cloud Datastore from existing Compute Engine with different project id?
body: <p>Google Cloud Datastore is a great way to share information between app engine and compute engine. <a href="https://developers.google.com/datastore/docs/activate" rel="nofollow">This instruction</a> shows how to use google cloud datastore from compute engine, but it seems both app engine and compute engine have to be in a same project id.</p>
  
  <p>My datastore inside app engine and compute engine have different project id.</p>
  
  <p>Here is what i did.
  in googledatastore/helper.py around line 65, added 1 line</p>
  
  <pre><code>  try:
      raise client.AccessTokenRefreshError # &lt;== added
      credentials = gce.AppAssertionCredentials(connection.SCOPE)
      http = httplib2.Http()
      credentials.authorize(http)
      credentials.refresh(http)
      logging.info('connect using compute credentials')
      return credentials
    except (client.AccessTokenRefreshError, httplib2.HttpLib2Error):
      if (os.getenv('DATASTORE_SERVICE_ACCOUNT')
          and os.getenv('DATASTORE_PRIVATE_KEY_FILE')):
        with open(os.getenv('DATASTORE_PRIVATE_KEY_FILE'), 'rb') as f:
          key = f.read()
        credentials = client.SignedJwtAssertionCredentials(
            os.getenv('DATASTORE_SERVICE_ACCOUNT'), key, connection.SCOPE)
        logging.info('connect using DatastoreSignedJwtCredentials')
        return credentials
  </code></pre>
  
  <p>Then ignored compute engine credential. after that just follow instruction for 'not from compute engine'.
  hm.. It doesn't look best way.</p>
  
  <p>Is it proper way to use datastore from compute engine under another project id?</p>