簡體   English   中英

嘗試運行 bigquery 時 gcloud auth 登錄問題 403 訪問被拒絕

[英]gcloud auth login issue 403 access denied when trying to run bigquery

編輯:似乎這只是基於谷歌驅動器文件的表的問題。 我正在使用身份驗證登錄,作業在 bigquery UI 中顯示為由我作為所有者運行,但返回此錯誤,盡管我應該對此數據及其所基於的文件擁有完整權限。

我在讓 gcloud 運行 bigquery 時遇到問題,它返回錯誤:

google.api_core.exceptions.Forbidden:403 訪問被拒絕:BigQuery BigQuery:獲取驅動器憑據時權限被拒絕。

我已經嘗試了所有各種登錄命令:

gcloud auth 應用程序-默認登錄

gcloud 身份驗證登錄

然后我被帶到瀏覽器並授予訪問權限,一切似乎都很好,但我仍然遇到同樣的錯誤。

運行以下命令時,我的帳戶顯示正常,我可以看到我的登錄憑據為 JSON 文件,但我只是不明白為什么它說我沒有訪問權限。

 gloud auth list

我可以將 go 放入 bigquery 並查看自己作為所有者請求的查詢,然后我可以在 bigquery 控制台中運行相同的查詢,但是當通過腳本請求時它不起作用。

這是我正在運行的代碼。 多人運行了這段代碼,確認它有效,他們沒有做任何與我不同的事情。

我認為我在 gcloud 登錄方面做錯了,但很難理解是什么。

 import streamlit as st import pandas as pd from datetime import datetime as dt from google.cloud import bigquery def load_data(query_file): with open(query_file, "r+") as query_file: query = query_file.read() client = bigquery.Client(project = "my-data") df = client.query(query).result().to_dataframe() return df def load_current_es(ttl=60 * 60 * 540): """Get current ES names and pod Args: None Returns: pd.Dataframe """ columns = {"full_name": "str"} df = load_data("data/current_es.sql") assert len(df) > 0, "Dataframe for current ES is empty" # correct data types df = df.astype(dtype=columns) return df df = load_current_es() print(df.head())

所以最終這被證明是一個 gcloud 身份驗證問題。

I had run gcloud auth login and gcloud auth application-default login --scopes https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/bigquery並認為這已授予驅動器訪問權限,但仍在鏈接到驅動器文件的表上收到錯誤 403 驅動器訪問被拒絕。 這很奇怪,因為它在 BQ ui 中顯示我作為所有者調用了這些工作,但似乎沒有按預期應用燙發。

解決方案是同時運行gcloud auth login --enable-gdrive-access然后它現在可以訪問所有表。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM