本文介绍了错误:服务帐户没有bigquery.jobs.create权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个具有大查询角色admin的服务帐户.我正在使用大查询PHP API.让我知道是否需要其他许可?

I created one service account with role big query admin.I am Using big query PHP API. Let me know if any other permission is required or not?

它给我一个错误,指出:

It gives me an error stating that the:

我想在bigquery上运行查询.请帮忙.

I wanted to run a query on bigquery. Please help.

以下是我的代码:

     $service = new Google_Service_Bigquery($client);


    $query = new Google_Service_Bigquery_QueryRequest($client);
      $query->setQuery('SELECT * FROM [xxx:xxx.xxs] LIMIT 1000;');

      $jobs = $service->jobs;
      $response = $jobs->query($project_id, $query);

      // Do something with the BigQuery API $response data
      print_r($response)

;

推荐答案

我在使用针对Node.js的BQ库时遇到了这个问题.

I ran into this problem using the BQ library for nodejs.

通过CLI登录到用户/服务帐户似乎并不总是足够的.我的服务帐户已通过身份验证,并且在GCP SDK Shell中具有正确的权限,但是我仍然得到service account does not have bigquery.jobs.create permission..

It seems being signed into a user/service account via the CLI is not always enough. My service account was authenticated and had the correct permissions in the GCP SDK Shell, but I still got service account does not have bigquery.jobs.create permission..

我能够通过使用客户端库方法简单地添加相同的服务帐户详细信息来解决此问题.我使用了 https://googleapis.dev/nodejs/bigquery/latest/BigQuery.html .

I was able to fix this by simply adding the same service account details, using the client library methods. I used https://googleapis.dev/nodejs/bigquery/latest/BigQuery.html.

对于nodejs,我只需要添加

In the case of nodejs, I just had to add

// Imports BigQuery library
const {BigQuery} = require('@google-cloud/bigquery');
// Create BQ Options - this object is what fixed the issue
const bqOptions = {};
bqOptions.projectId = '*your-project-name*';
bqOptions.keyFilename = '*Path-to-service-account-private-key*';
// Creates BQ client
const bq = new BigQuery(bqOptions);

我知道您正在使用PHP库,但是我认为等效的PHP可以相同地工作.

I know you are using the PHP library, but I think the PHP equivalent would work the same.

这篇关于错误:服务帐户没有bigquery.jobs.create权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:19