本文整理汇总了Python中h.auth.policy.TokenAuthenticationPolicy.authenticated_userid方法的典型用法代码示例。如果您正苦于以下问题:Python TokenAuthenticationPolicy.authenticated_userid方法的具体用法?Python TokenAuthenticationPolicy.authenticated_userid怎么用?Python TokenAuthenticationPolicy.authenticated_userid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类h.auth.policy.TokenAuthenticationPolicy
的用法示例。
在下文中一共展示了TokenAuthenticationPolicy.authenticated_userid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_authenticated_userid_uses_callback
# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import authenticated_userid [as 别名]
def test_authenticated_userid_uses_callback(self, pyramid_request):
def callback(userid, request):
return None
policy = TokenAuthenticationPolicy(callback=callback)
pyramid_request.auth_token = 'valid123'
result = policy.authenticated_userid(pyramid_request)
assert result is None
示例2: test_authenticated_userid_uses_callback
# 需要导入模块: from h.auth.policy import TokenAuthenticationPolicy [as 别名]
# 或者: from h.auth.policy.TokenAuthenticationPolicy import authenticated_userid [as 别名]
def test_authenticated_userid_uses_callback(self, jwt, api_token):
def callback(userid, request):
return None
policy = TokenAuthenticationPolicy(callback=callback)
api_token.return_value = 'acct:[email protected]'
jwt.return_value = None
request = DummyRequest(headers={'Authorization': 'Bearer f00ba12'})
result = policy.authenticated_userid(request)
assert result is None