Search code examples
google-cloud-platformgoogle-cloud-mlgoogle-cloud-nl

gcloud ml language Request had insufficient authentication scopes


For a relatively small academic research project, I am trying to use Google Cloud Natural Language API.

From what I understood on the Authentication Overview, it looks like an API key would be the best and simplest approach to authentication, rather than a service account or user account.

Creating the key was easy enough. But now I am stuck on how to actually use it in conjunction with gcloud commands on an Ubuntu VM instance on Google cloud compute engine.

When I try to run the simple example on the Natural Language Quickstart Guide, I get this error:

gcloud ml language analyze-entities --content="Michelangelo Caravaggio, Italian painter, is known for 'The Calling of Saint Matthew'."

ERROR: (gcloud.ml.language.analyze-entities) PERMISSION_DENIED: Request had insufficient authentication scopes.

The documentation and Q&A I've seen related to this error are related to service accounts or user accounts, but I am trying to just use the "simple" API key.

The documentation for Using an API key shows how to do so via REST. But, for now as a "quick" test to see if I have the Natural Language API working, I want to just do a simple test with gcloud on the command line. I looked through the gcloud documentation, but could not find anything about specifying an API key string.

How can I run the above command with gcloud and authenticate with my API key?

If this API key turns out to be more of a hassle, I may consider switching to a service account.

Any help would be greatly appreciated...


Solution

  • Got this to work by:

    From Google Cloud console: Compute Engine -> VM instances

    Click name of existing VM, which brings up VM instance details page. Click "Edit" link near the top of the page.

    Then modify Cloud API access scopes to allow full access to all Cloud APIs.