这个错误是由于Google Cloud身份验证过期引起的。解决此问题的方法是重新获取身份验证令牌。以下是一个示例代码来获取新的身份令牌:
from google.oauth2 import service_account
from google.auth.transport.requests import Request
from google.cloud import bigquery
credentials = service_account.Credentials.from_service_account_file("path/to/service_account.json")
# refresh the credentials
if credentials.expired and credentials.refresh_token:
credentials.refresh(Request())
client = bigquery.Client(credentials=credentials)
# use the client for your BigQuery operations
此代码将检查是否过期,并在需要时刷新凭据。您只需将path/to/service_account.json
替换为您的服务帐户文件路径,然后使用Client
创建BigQuery客户端实例。