当前位置: 首页 > 面试题库 >

出现错误:redirect_uri_mismatch请求中的重定向URI:http:// localhost:8080 / oauth2callback与注册的重定向URI不匹配

安经纶
2023-03-14
问题内容

尝试运行我的应用程序时出现此错误…

The redirect URI in the request: http://localhost:8080/oauth2callback did not match a registered redirect URI

在Google API控制台中,我已经注册了重定向网址

Redirect URIs:  http://localhost:8080/

而且在client_secrets.json中,我也使用与重定向URL相同的名称,我在遵循本教程
https://developers.google.com/bigquery/articles/dashboard#addoauth2

编辑:

我刚刚对现有代码进行了一些更改

现在

redirect URIs in API console is     http://localhost:8080/oauth2callback

这是我的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

现在,尽管它没有显示任何错误,但是显示了一个空白页。

这是我的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()

因此,根据main.py,如果一切正常,则必须打印Hello Dashboard,但事实并非如此


问题答案:

实际上,您将需要在重定向URI中添加以下内容:

http://localhost:8080/oauth2callback

另外,/如果以上条件不匹配,则可能需要附加尾随:

http://localhost:8080/oauth2callback/


 类似资料:
  • 问题内容: 我试图从基于Java的网络应用程序上传到YouTube,花了几天的时间来了解问题所在和出处,但我无法解决,因为现在我将头发拔掉了。 我在Google控制台中注册了Web应用程序,因此获得了一对Client ID和Secret,并可以通过配置下载JSON类型文件。 所以这是配置: 我如何从Google获取默认URL? 它总是给我默认的URL,而不是我的。 IDE控制台向我显示: 我正在使

  • 我正在通过这个sdk集成Instagram登录https://github.com/crino/instagram-ios-sdk 我用重定向URI"http://www.webvillee.com/callback"注册了我的应用程序,并获得了客户端ID和秘密ID。 现在,当我想通过应用程序登录时,它显示错误400“重定向URI与注册的重定向URI不匹配”。 我还试图在安全会话中用ig Clie

  • 我试图发出授权请求,但收到错误: 重定向URI未正确注册到DocuSign 这是我正在使用的URL: https://account-d.docusign.com/oauth/auth?response_type=code 这是我注册的重定向URI,与上面的URL匹配: 这是错误: 客户端id与integrator密钥匹配。 有什么指点吗?

  • 我的DocuSign重定向URI似乎有错误。登录时它似乎没有正确注册。 错误:“重定向URI未正确注册到DocuSign”。

  • 使用授权代码流拥有一个受Spring Security oAuth2保护的Spring boot mvc应用程序。当在本地机器上部署和运行时,应用程序将重定向到正确的重定向uri以进行登录。但是在我们的kubernetes部署中,应用程序前面有一个api网关,可以通过以下路径访问应用程序 https:/// 其中k8名称空间名称是kubernetes名称空间名称,app名称是应用程序在名称空间中的

  • 当我为Google OAuth请求使用以下URI时,我得到以下错误: “域与重定向\u uri/origin不匹配。错误代码:2”。 谁能告诉我我做错了什么? https://accounts.google.com/o/oauth2/auth?client_id=client_id_copied_from_the_developer_console