Terminal --递归错误:权限不足:请求的身份验证作用域不足

Terminal --递归错误:权限不足:请求的身份验证作用域不足,terminal,google-cloud-platform,gcloud,Terminal,Google Cloud Platform,Gcloud,我正在尝试使用以下命令将目录从vm复制到本地计算机的桌面: gcloud compute scp --recurse instance-1:~/directory ~/Desktop/ 我尝试用“gcloud auth login”重新验证,但它仍然显示 ERROR: (gcloud.compute.scp) Could not fetch resource: - Insufficient Permission: Request had insufficient authentication

我正在尝试使用以下命令将目录从vm复制到本地计算机的桌面:

gcloud compute scp --recurse instance-1:~/directory ~/Desktop/
我尝试用“gcloud auth login”重新验证,但它仍然显示

ERROR: (gcloud.compute.scp) Could not fetch resource:
 - Insufficient Permission: Request had insufficient authentication scopes.
尝试从尝试运行gcloud命令的计算机上运行“gcloud auth login”


有关更多信息,他们正在报告相同的问题。

您将需要
角色/compute.instanceAdmin.v1
对您正在使用的凭据的实例使用SSH或SCP。最简单的方法是将
Compute Instance Admin
添加到凭据中

要查看您使用的凭据,请执行
gcloud auth list
。账户的左列将有一个星号


要了解您有哪些权限执行
gcloud项目,请获取iam策略项目\u ID

提供完整的代码,以便更好地理解

private static void upload() throws GeneralSecurityException, IOException {
    final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
    Drive driveService = new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
            .setApplicationName(APPLICATION_NAME)
            .build();
    File fileMetadata = new File();

    fileMetadata.setName("My Report");
    fileMetadata.setMimeType("application/vnd.google-apps.spreadsheet");

    java.io.File filePath = new java.io.File("/exportData.csv");
    FileContent mediaContent = new FileContent("text/csv", filePath);
    File file = driveService.files().create(fileMetadata, mediaContent)
            .setFields("id")
            .execute();
    System.out.println("File ID: " + file.getId());
}