iJa*_*ade 11 python google-app-engine oauth-2.0 google-bigquery
我在尝试运行我的应用程序时收到此错误...
The redirect URI in the request: http://localhost:8080/oauth2callback did not match a registered redirect URI
Run Code Online (Sandbox Code Playgroud)
在谷歌API控制台中,我已经注册了我的重定向网址
Redirect URIs: http://localhost:8080/
Run Code Online (Sandbox Code Playgroud)
在client_secrets.json中我也使用与重定向url相同的内容我正在按照本教程 https://developers.google.com/bigquery/articles/dashboard#addoauth2
编辑:
我刚刚对现有代码进行了一些更改
现在
redirect URIs in API console is http://localhost:8080/oauth2callback
Run Code Online (Sandbox Code Playgroud)
这是我的app.yaml
application: hellomydashboard
version: 1
runtime: python
api_version: 1
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /oauth2callback
script: oauth2client/appengine.py
- url: .*
script: main.py
Run Code Online (Sandbox Code Playgroud)
现在虽然它没有显示任何错误,但它显示一个空白页面.
这是我的main.py
from bqclient import BigQueryClient
import httplib2
import os
from google.appengine.api import memcache
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from oauth2client.appengine import oauth2decorator_from_clientsecrets
# 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
# REPLACE THIS NUMBER WITH YOUR CLIENT ID
PROJECT_ID = "My Project ID" #i just replaced dat
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.out.write("Hello Dashboard!\n")
application = webapp.WSGIApplication([
('/', MainHandler),
], debug=True)
def main():
run_wsgi_app(application)
if __name__ == '__main__':
main()
Run Code Online (Sandbox Code Playgroud)
所以根据main.py,如果一切正常,它必须打印Hello Dashboard,但事实并非如此
Roc*_*key 18
您实际上需要将以下内容添加到重定向URI:
http://localhost:8080/oauth2callback
Run Code Online (Sandbox Code Playgroud)
此外,/如果上述内容不匹配,您可能需要附加一个尾随:
http://localhost:8080/oauth2callback/
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
32654 次 |
| 最近记录: |