我正在学习本教程
https://developers.google.com/bigquery/docs/authorization#service-accounts-appengine
这是我的main.py代码
import httplib2
from apiclient.discovery import build
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from oauth2client.appengine import AppAssertionCredentials
# BigQuery API Settings
SCOPE = 'https://www.googleapis.com/auth/bigquery'
PROJECT_NUMBER = 'XXXXXXXXXX' # REPLACE WITH YOUR Project ID
# Create a new API service for interacting with BigQuery
credentials = AppAssertionCredentials(scope=SCOPE)
http = credentials.authorize(httplib2.Http())
bigquery_service = build('bigquery', 'v2', http=http)
class ListDatasets(webapp.RequestHandler):
def get(self):
datasets = bigquery_service.datasets()
listReply = datasets.list(projectId=PROJECT_NUMBER).execute()
self.response.out.write('Dataset list:')
self.response.out.write(listReply)
application = webapp.WSGIApplication(
[('/listdatasets(.*)', ListDatasets)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
这是我的app.yaml文件代码
application: bigquerymashup
version: 1
runtime: python
api_version: 1
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.py
是的,我已经在谷歌api控制台的“团队”选项卡中添加了应用引擎服务帐户名称,可以编辑权限。 上传应用程序并尝试访问链接时显示
Oops! This link appears to be broken.
Ealier我在本地运行并试图使用链接localhost:8080
访问它。然后我认为可能在本地运行可能会出错,所以我上传了我的代码
http://bigquerymashup.appspot.com/
但仍然给出错误。
修改 更新了App.yaml
application: bigquerymashup
version: 1
runtime: python
api_version: 1
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.py
- url: /listdatasets
script: main.py
但是又出现了另一个错误
Traceback (most recent call last): File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 710, in call handler.get(*groups) TypeError: get() takes exactly 1 argument (2 given)
答案 0 :(得分:1)