我正在完成https://developers.google.com/bigquery/articles/dashboard
的开始教程我正处于“构建仪表板”阶段,但是当我通过谷歌应用程序引擎运行程序时,我能够登录,Hello仪表板要求我使用BigQuery管理我的数据的权限(会发布截图但我的代表太低了)。当我接受这个时,它只会把我带到一个空白页面。但是来自main.py的代码建议它应该打印到页面“Hello Dash!Last mod time = somenumbers”。
有趣的是,当我使用谷歌应用引擎部署此程序时出现错误:redirect_uri_mismatch显示。现在,在你询问我的redirct uri在谷歌应用程序控制台中是否相同之前,它被设置为http:// localhost:8080 / oauth2callback,它在我的client_secrets.json代码引用中完全相同。 <<这已经修复,在谷歌控制台中更改客户端ID后,它现在加载,但是当它应该显示“你好破折号”时我仍然得到空白屏幕!来自main.py中的写入响应行
我已提到Getting Error: redirect_uri_mismatch The redirect URI in the request: http://localhost:8080/oauth2callback did not match a registered redirect URI此链接问题非常相似,但答案中没有一个是令人满意的。我试过了所有这些。
main.py
from bqclient import BigQueryClient
import os
import httplib2
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
#from apiclient.discovery import build
from oauth2client.appengine import oauth2decorator_from_clientsecrets
from google.appengine.api import memcache
# Project ID for project to receive bill.
# During limited availability preview, there is no bill.
# The value should be your quoted Client ID number
# which you previously recorded from code.google.com/apis/console
PROJECT_ID = "client_id"
DATASET = "samples"
TABLE = "natality"
# CLIENT_SECRETS, name of a file containing the OAuth 2.0
# information for this application.
CLIENT_SECRETS = os.path.join(os.path.dirname(__file__), 'client_secrets.json')
http = httplib2.Http(memcache)
decorator = oauth2decorator_from_clientsecrets(CLIENT_SECRETS,
'https://www.googleapis.com/auth/bigquery')
bq = BigQueryClient(http, decorator)
class MainHandler(webapp.RequestHandler):
@decorator.oauth_required
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write("""Hello dash!\n""")
modTime = bq.getLastModTime(PROJECT_ID, DATASET, TABLE)
if modTime is not None:
msg = 'Last mod time = ' + modTime
else:
msg = "Could not find last modification time.\n"
self.response.out.write(msg)
application = webapp.WSGIApplication([('/', MainHandler)], debug=True)
def main():
run_wsgi_app(application)
if __name__ == '__main__':
main()}
的app.yaml
application: exalted-mode-398
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /oauth2callback
script: oauth2client/appengine.py
- url: /.*
script: main.py
的client_secrets.json
{
"web": {
"client_id": "client_id",
"client_secret": "secret_number",
"redirect_uris": ["http://localhost:8080/oauth2callback"],
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token"
}
}
有谁知道我为什么会收到此错误???
此外,由于显而易见的原因,我删除了我的密码和client_id