【发布时间】:2017-05-21 22:18:23
【问题描述】:
我正在尝试执行 http 请求以获取由另一个脚本提交的作业的信息。该脚本具有作业 ID 和项目。我在 Oauth20 上阅读并看到使用 Application Default Credentials 是推荐的方式。 我已导出默认身份验证:
export GOOGLE_APPLICATION_CREDENTIALS= /test/proj-service-key-file.json
这是我的代码:
from google.oauth2.service_account import Credentials
from google.cloud import bigquery
import requests
from oauth2client.client import GoogleCredentials
from google.auth.transport.requests import AuthorizedSession
import google.auth
credentials = GoogleCredentials.get_application_default()
session = google.auth.transport.requests.AuthorizedSession(credentials)
job_url="https://www.googleapis.com/bigquery/v2/projects/" + self.project + "/jobs/" + job_id + "?maxResults=1"
job_query_results = session.request('GET',job_url)
我收到以下错误:
self.credentials.before_request(
AttributeError: '_JWTAccessCredentials' 对象没有属性 'before_request'
感谢任何建议。
【问题讨论】:
标签: google-bigquery google-authentication