什么是AppIdentityError:错误的收件人?

时间:2015-01-15 16:11:49

标签: python oauth-2.0 google-oauth google-client

我有一个简单的Python服务器来验证Google oauth2 id_tokens。执行此代码时,会抛出错误AppIdentityError: Wrong recipient

def verify():
    id_token = request.form['id_token']
    status = {}
    if id_token is not None:
        try:
            jwt = verify_id_token(id_token, config['google']['clientId'])
            status['valid'] = True
            status['jwt'] = jwt
        except AppIdentityError:
            status['valid'] = False
            status['message'] = "Invalid id token"
    pprint.pprint(status)
    response = make_response(json.dumps(status))
    response.headers['Content-Type'] = 'application/json'
    return response

AppIdentityError: Wrong recipient的含义是什么?如何解决?

1 个答案:

答案 0 :(得分:0)

您要验证的JWT包含受众群体(aud)值。该错误是aud值与预期值不匹配的结果。

我不确定您正在使用哪个库,但在identity-toolkit-python-client软件包中,VerifyGitTotken函数会查看为验证JWT而提供的project_id和client_id值。

当我遇到此错误时,结果发现我的gitkit-server-config.json文件与Google开发者控制台提供的文件不匹配。这些值在API Manager>>上提供。概述>> Identity Toolkit API页面。

我更正了我的json文件,错误消失了。