【问题标题】:Django & Google Auth - Error 400 (OAuth2 Error)!!1Django 和 Google 身份验证 - 错误 400(OAuth2 错误)!!1
【发布时间】:2017-05-31 22:31:05
【问题描述】:

我在 Django 11.1 的 oauth2client 文档中实现了以下视图:

@oauth_required
def get_profile_required(request):
    resp, content = request.oauth.http.request(
        'https://www.googleapis.com/plus/v1/people/me')
    return HttpResponse(content)


@oauth_enabled
def get_profile_optional(request):
    if request.oauth.has_credentials():
        # this could be passed into a view
        # request.oauth.http is also initialized
        return HttpResponse('User email: {}'.format(
            request.oauth.credentials.id_token['email']))
    else:
        return HttpResponse(
            'Here is an OAuth Authorize link:<a href="{}">Authorize</a>'
            .format(request.oauth.get_authorize_redirect()))

页面似乎可以正常工作,但是当我尝试浏览流程时,我收到 400 错误,说它是 Error: redirect_uri_mismatch。我试图将我的域添加到密钥的凭据部分,但我找不到它。这是我看到的截图:

我应该去别处寻找吗?这是权限问题吗?

【问题讨论】:

    标签: python django oauth-2.0 google-oauth


    【解决方案1】:

    想通了!显然,我在 Oauth ClientID 创建页面上为Application Type 选择了“其他”,而不是“Web 应用程序”。这样做解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2016-03-27
      • 2014-05-10
      • 2021-10-16
      • 2021-03-26
      • 2018-01-19
      • 2020-10-15
      • 2014-06-07
      • 2017-01-04
      • 1970-01-01
      相关资源
      最近更新 更多