本文整理汇总了Python中models.Client.find_one方法的典型用法代码示例。如果您正苦于以下问题:Python Client.find_one方法的具体用法?Python Client.find_one怎么用?Python Client.find_one使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Client
的用法示例。
在下文中一共展示了Client.find_one方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_rsa_key
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def get_rsa_key(self, client_key):
client = Client.find_one({'client_key':client_key})
if client:
return client.get('pubkey')
else:
return None
示例2: get_client_secret
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def get_client_secret(self, client_key):
client = Client.find_one({'client_key':client_key})
if client:
return client.get('secret')
else:
return None
示例3: get_realm
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def get_realm(self, client_key, request_token):
client = Client.find_one({'client_key':client_key})
if client:
return RequestToken.find_one(
{'token':request_token, 'client_id': client['_id']})['realm']
else:
return None
示例4: save_request_token
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def save_request_token(self, client_key, request_token, callback,
realm=None, secret=None):
client = Client.find_one({'client_key':client_key})
if client:
token = RequestToken(
request_token, callback, secret=secret, realm=realm)
token.client_id = client['_id']
RequestToken.insert(token)
示例5: validate_access_token
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def validate_access_token(self, client_key, resource_owner_key):
token = None
client = Client.find_one({'client_key':client_key})
if client:
token = AccessToken.find_one(
{'token':resource_owner_key, 'client_id': client['_id']})
return token != None
示例6: validate_verifier
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def validate_verifier(self, client_key, resource_owner_key, verifier):
token = None
client = Client.find_one({'client_key':client_key})
if client:
token = RequestToken.find_one(
{'token':resource_owner_key,
'client_id': client['_id'],
'verifier':verifier})
return token != None
示例7: save_request_token
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def save_request_token(self, client_key, request_token, callback,
realm=None, secret=None):
client = Client.find_one({'client_key':client_key})
if client:
token = RequestToken.find_or_create(realm = realm,
user_id = current_user.get_id(), client_id = client['_id'])
token.token = request_token
token.callback = callback
token.secret = secret
token.save()
示例8: get_realm
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def get_realm(self, client_key, request_token):
client = Client.find_one({'client_key':client_key})
if client:
token = RequestToken.find_one(
{'token':request_token, 'client_id': client['_id']})
if token:
return token.get('realm')
return None
示例9: get_access_token_secret
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def get_access_token_secret(self, client_key, resource_owner_key):
client = Client.find_one({'client_key':client_key})
if client:
token = AccessToken.find_one(
{'token':resource_owner_key,
'client_id': client['_id']})
if token:
return token['secret']
return None
示例10: get_request_token_secret
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def get_request_token_secret(self, client_key, resource_owner_key):
client = Client.find_one({'client_key':client_key})
if client:
token = RequestToken.find_one(
{'token':resource_owner_key,
'client_id': client['_id']})
if token:
return token.get('secret')
return None
示例11: save_access_token
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def save_access_token(self, client_key, access_token, request_token,
realm=None, secret=None):
client = Client.find_one({'client_key':client_key})
if client:
token = AccessToken(access_token, secret=secret, realm=realm)
token.client_id = client['_id']
req_token = RequestToken.find_one({'token':request_token})
if req_token:
token['resource_owner_id'] = req_token['resource_owner_id']
token['realm'] = req_token['realm']
AccessToken.insert(token)
示例12: validate_request_token
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def validate_request_token(self, client_key, resource_owner_key):
# TODO: make client_key optional
token = None
if client_key:
client = Client.find_one({'client_key':client_key})
if client:
token = RequestToken.find_one(
{'token':access_token, 'client_id': client['_id']})
else:
token = RequestToken.find_one(
{'token':resource_owner_key})
return token != None
示例13: validate_realm
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def validate_realm(self, client_key, access_token, uri=None, required_realm=None):
if not required_realm:
return True
# insert other check, ie on uri here
client = Client.find_one({'client_key':client_key})
if client:
token = AccessToken.find_one(
{'token':access_token, 'client_id': client['_id']})
if token:
return token['realm'] in required_realm
return False
示例14: save_timestamp_and_nonce
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def save_timestamp_and_nonce(self, client_key, timestamp, nonce,
request_token=None, access_token=None):
client = Client.find_one({'client_key':client_key})
if client:
nonce = Nonce(nonce, timestamp)
nonce.client_id = client['_id']
if request_token:
req_token = RequestToken.find_one({'token':request_token})
nonce.request_token_id = req_token['_id']
if access_token:
token = AccessToken.find_one({'token':access_token})
nonce.access_token_id = token['_id']
nonce.insert()
示例15: validate_timestamp_and_nonce
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import find_one [as 别名]
def validate_timestamp_and_nonce(self, client_key, timestamp, nonce,
request_token=None, access_token=None):
token = True
req_token = True
client = Client.find_one({'client_key':client_key})
if client:
nonce = Nonce.find_one({'nonce':nonce, 'timestamp':timestamp,
'client_id':client['_id']})
if nonce:
if request_token:
req_token = RequestToken.find_one(
{'_id':nonce['request_token_id'], 'token':request_token})
if access_token:
token = RequestToken.find_one(
{'_id':nonce['request_token_id'], 'token':access_token})
return token and req_token and nonce != None