【发布时间】:2016-02-10 18:58:17
【问题描述】:
我正在尝试从我的 Python 脚本访问 BigQuery API。目前我只是在尝试让this sample 运行。
我创建了凭据,设置了环境变量并运行了脚本,却得到了这个错误:
oauth2client.client.ApplicationDefaultCredentialsError: An error was encountered while reading json file: /PATH/TO/MY/google_api_credentials.json (pointed to by GOOGLE_APPLICATION_CREDENTIALS environment variable): 'type' field should be defined (and have one of the 'authorized_user' or 'service_account' values)
嗯,它没有在 JSON 文件中设置:
{"installed":{"client_id":"blahblah.apps.googleusercontent.com","project_id":"blahblah","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"blahblah","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}
既然我从 Google 控制台下载了 JSON,它应该可以工作吗?我不知道我需要定义什么“类型”。
【问题讨论】:
标签: python google-app-engine google-api google-oauth google-api-python-client