我正在尝试将我的GCP项目appengine应用程序连接到Bigquery,我正面临访问问题(禁止403)。
我按照此处提供的参考资料: https://cloud.google.com/bigquery/docs/reference/libraries#client-libraries-usage-python
我收到错误:
Project sample-1423: The user sample-1423@appspot.gserviceaccount.com does not have bigquery.jobs.create permission in project sample-1423
代码:
user = users.get_current_user()
client = bigquery.Client()
auth_query = AUTH_QUERY
params = (bigquery.ScalarQueryParameter('email', 'STRING', user.email()),)
auth_job = client.run_async_query(
str(uuid.uuid4()), auth_query, query_parameters=params)
auth_job.use_legacy_sql = False
auth_job.begin()
auth_job.result()
table = auth_job.destination
table.reload()
错误:
Traceback (most recent call last):
File "/Users/user/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/Users/user/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/Users/user/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/Users/user/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/Users/user/projects/sample/main.py", line 43, in dispatch
if not user_in_system():
File "/Users/user/projects/sample/main.py", line 30, in user_in_system
auth_job.begin()
File "/Users/user/projects/sample/lib/google/cloud/bigquery/job.py", line 373, in begin
method='POST', path=path, data=self._build_resource())
File "/Users/user/projects/sample/lib/google/cloud/_http.py", line 293, in api_request
raise exceptions.from_http_response(response)
Forbidden: 403 POST https://www.googleapis.com/bigquery/v2/projects/sample-1432/jobs: Access Denied: Project sample-1432: The user sample-1432@appspot.gserviceaccount.com does not have bigquery.jobs.create permission in project sample-1432.