谷歌oAuth2令牌访问中的redirect_uri_mismatch问题

3

我正在尝试使用Google oAuth2从一次性代码中访问令牌。但是,响应中出现了错误消息redirect_uri_mismatch。然而,我已经在控制台中添加了redirect_uri

我的Authorized redirect uri如下:

http://localhost:3020/api/users/google_oauth_store_token

我的请求:

Request URL = https://www.googleapis.com/oauth2/v3/token?code=xXXXxx&client_id=xxxxxx&client_secret=xxx&redirect_uri=http://localhost:3020/api/users/google_oauth_store_token&grant_type=authorization_code

我的回答:

  response = {
    "error": "redirect_uri_mismatch",
    "error_description": "Bad Request"
  }
1个回答

0

那是我的错误。我必须使用我在一次性重定向URI中使用过的redirect_uri。Google使用其中一个redirect_uri来重置客户端来源。


5
能否请您详细说明一下您的解决方案? - tixastronauta
@tixastronauta 前往您的Google开发者控制台>然后前往API管理器>单击凭据>C进入Web客户端服务。您将看到客户端ID和客户端密钥。在下面某个地方,您将找到已授权的重定向URI。只需添加您的重定向URI,例如`www.example.com/oauth'。现在谷歌将使用列出的重定向URI之一。它将解决您的问题。对我有用。我的错误是我添加了错误的重定向URI。 :) - CodeGeeky
@CodeGeeky 我正在使用 Postman 调用 API,但它总是返回相同的错误。 - ngLover
3
我已经将我的URL(子域名URL)添加到授权重定向URI中,但仍然出现相同的错误。 - Atul Baldaniya

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接