Cannot connect to datastore

NK4
New Member

I tried to connect datastore using service account, I have given role as owner. Once service account is created, in the Managed keys option, added key and generate token as JSON, finally exported as env in intellji. I am getting below exception

Exception: Cloud Datastore API has not been used in project xxxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/datastore.googleapis.com/overview?project=xxxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

I already enabled datastore API. Please anyone can help

0 1 246
1 REPLY 1

Here are some suggestions on how to troubleshoot further:

  1. Verify API Activation:

    • Account Access: Ensure you're logged in to the Google Cloud Console with an account that has view and manage permissions for the project.
    • Double-check Project: Verify the Datastore API status is Enabled under the correct Google Cloud project: Verify Datastore API status 
    • Propagation Delay: API activation can take a few minutes to propagate. Wait for 5-10 minutes and retry connection.
  2. Service Account Configuration:

    • Valid JSON Key: Ensure the service account's JSON key file is valid, accessible, and not expired or revoked. Do not share the JSON key file publicly and handle it securely.
    • Full Path in Env Variable: Set GOOGLE_APPLICATION_CREDENTIALS to the full file path of the JSON key, not just the directory.
    • Role: Make sure the service account has the "Datastore Owner" role or other suitable permissions for Datastore access.
    • Code Reference: Check your code properly references the service account credentials when connecting.
  3. Network Issues:

    • Connectivity: Confirm your network connectivity. Can you access other Google Cloud services?
    • Corporate Network: If on a corporate network, check for egress controls or proxy settings that might block Google Cloud APIs.
    • Different Network: Try accessing the Datastore API from another network environment to rule out local network issues. If testing from home, ensure your personal firewall or antivirus isn't blocking the connection.
    • Project ID: Verify you're using the correct project ID in your connection configuration.
  4. Additional Resources:

  5. Further Assistance:

Additional Information:

  • Share Code Snippet: Share the code related to your Datastore connection attempt, removing any API keys or other sensitive information before sharing.
  • Development Environment: Specify the environment you're using (e.g., IntelliJ plugin, local emulator).
  • Error Messages/Logs: Provide relevant error messages and logs related to the connection attempt.
  • gcloud command: Use the following gcloud command to check if the Datastore API is enabled:
     
    gcloud services list | grep datastore.googleapis.com