google-cloud-platformauthorizationgcloudservice-accountsscopes

Insufficient Authentication Scopes Error When Using gcloud CLI to Manage Google Cloud VMs


I have a situation with Google Cloud involving two virtual machines:

My goal is to manage instance2 from instance1 using the gcloud CLI, utilizing the service account XXXXXXXXXXXX-compute@developer.gserviceaccount.com. To achieve this, I'm attempting to run the following command in the CMD console within instance1:

gcloud compute instances describe instance2 --zone=my-zone --project=my-project

Unfortunately, I'm encountering an error:

ERROR: (gcloud.compute.instances.describe) Could not fetch resource:
 - Request had insufficient authentication scopes.

Strangely, executing the same command on my local PC using the identical service account works without any problems.

Has anyone else encountered a similar problem, and can you provide any insights into what might be causing this "insufficient authentication scopes" error? I would appreciate any suggestions on how to troubleshoot and resolve this issue. Thank you for your help!


Solution

  • Requests had insufficient authentication scopes error can be caused by a number of causes such as insufficient permissions, wrong project or cluster names, and an outdated Google Cloud SDK.

    To fix this error:

    If you are using the cloud console, when creating a VM look for the "Identity and API access" section, and select "Allow full access to all Cloud APIs".

    Steps to follow:

    1. Navigate to the Google Cloud Console: VM instances -> Compute Engine

    2. Clicking the name of an existing VM opens the VM instance details page.

    3. Near the top of the page, click the "Edit" link.

    4. Then, change the Cloud API access scopes to allow complete access to all Cloud APIs.

    To figure out what permissions you have execute

    gcloud projects get-iam-policy PROJECT_ID
    

    You can also refer to this official doc for the related information.