获取错误:redirect_uri_mismatch请求中的重定向URI:http:// localhost:8080 / oauth2callback与注册的重定向URI不匹配 [英] Getting Error: redirect_uri_mismatch The redirect URI in the request: http://localhost:8080/oauth2callback did not match a registered redirect URI
问题描述
请求中的重定向URI:http :// localhost:8080 / oauth2callback与注册的重定向URI不匹配
在google API控制台中,我有注册我的重定向url
重定向URI:http:// localhost:8080 /
而在client_secrets.json中,我也使用了相同的重定向url
我正在关注本教程
https://developers.google.com/bigquery/articles/dashboard#addoauth
编辑:
我只是对现有代码进行了一些更改
现在API控制台中的重定向URI是http:// localhost:8080 / oauth2callback
<$ p
$ b
/ code>
这里是我的app.yaml
application:hellomydashb oard
版本:1
运行时:python
api_version:1
处理程序:
- url:/favicon\.ico
static_files :favicon.ico
上传:favicon \.ico
- url:/ oauth2callback
脚本:oauth2client / appengine.py
- url: 。*
script:main.py
现在虽然没有显示任何错误,但它显示一个空白页。
这是我的main.py
from bqclient import BigQueryClient
导入httplib2
从google.appengine.api导入os
从google.appengine.ext导入memcache
从google.appengine.ext导入webapp
。 webapp.util从oauth2client.appengine导入run_wsgi_app
导入oauth2decorator_from_clientsecrets
#项目接收账单的项目ID。
#在有限的可用性预览期间,没有帐单。
#该值应该是您之前从code.google.com/apis/console
记录的您报价的客户端ID号码
##用您的客户端ID $替换此号码b $ b PROJECT_ID =我的项目ID#i刚取代dat
DATASET =samples
TABLE =natality
#CLIENT_SECRETS,包含OAuth 2.0
#此应用程序的信息。
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,装饰器)
class MainHandler(webapp.RequestHandler):
@ decorator.oauth_required
def get(self):
self.response.out.write(Hello Dashboard!\\\
)
application = webapp.WSGIApplication([
('/',MainHandler),
],debug = True)
def main ):
run_wsgi_app(应用程序)
$ b $如果__name__ =='__main__':
main()
因此,根据main.py,如果一切正常,它必须打印Hello Dashboard,但它不是
http:// localhost: 8080 / oauth2callback
另外,您可能需要追加尾随 /
如果以上不匹配:
http:// localhost:8080 / oauth2callback /
I'm getting this error while trying to run my application...
The redirect URI in the request: http://localhost:8080/oauth2callback did not match a registered redirect URI
In google API console i have registered my redirect urls
Redirect URIs: http://localhost:8080/
And in the client_secrets.json also i'm using the same as redirect url I'm following this tutorial https://developers.google.com/bigquery/articles/dashboard#addoauth2
Edit:
I just made some changes to the existing code
Now the
redirect URIs in API console is http://localhost:8080/oauth2callback
And here is my 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
Now though its not showing any error but it displays a blank page.
Here is my 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()
So according to main.py if everything is fine it must print Hello Dashboard but it isn't
You will actually need to add the following to your redirect URIs:
http://localhost:8080/oauth2callback
Also, you may need to append a trailing /
if the above doesn't match:
http://localhost:8080/oauth2callback/
这篇关于获取错误:redirect_uri_mismatch请求中的重定向URI:http:// localhost:8080 / oauth2callback与注册的重定向URI不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!