作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从 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,它应该可以正常工作吗?我不知道我需要定义什么“类型”。
最佳答案
您提供的 JSON 文件适用于 OAuth 客户端。当您使用应用程序默认凭据时,您需要提供 JSON 服务帐户 key 。尝试访问this page ,单击“创建服务帐户”,填写表单,然后选择“提供新的私钥”。
关于python - 应设置 oauth2client.client.ApplicationDefaultCredentialsError : 'type' , 'authorized_user' 或 'service_account' 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35323658/
我正在尝试从 Python 脚本访问 BigQuery API。目前我正在尝试只是想获得 this sample运行。 我创建了凭据,设置了环境变量并运行了脚本,却收到此错误: oauth2clien
我是一名优秀的程序员,十分优秀!