本文整理匯總了Python中auth.authenticate方法的典型用法代碼示例。如果您正苦於以下問題:Python auth.authenticate方法的具體用法?Python auth.authenticate怎麽用?Python auth.authenticate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類auth
的用法示例。
在下文中一共展示了auth.authenticate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: on_post
# 需要導入模塊: import auth [as 別名]
# 或者: from auth import authenticate [as 別名]
def on_post(self, req, resp):
validRequest = authenticate(req)
if not validRequest:
resp.body = "Invalid username/password"
resp.status = falcon.HTTP_401
return
session = Session(engine)
valueDict = getJson(req)
signatureQuery = getSignatureQuery(req, session)
message = "Unable to add Signature"
resp.status = falcon.HTTP_400
if "Signature" in valueDict.keys() and signatureQuery is None:
signatureRow = createSignatureRow(session, valueDict)
message = "Unable to create signature row"
if signatureRow is not None:
session.add(signatureRow)
message = "Added signature to database: {}".format(signatureRow.PrimaryKey)
resp.status = falcon.HTTP_200
elif "Signature" in valueDict.keys():
message = "Unable to add Signature, already exists in database"
resp.body = message
print(message)
session.commit()
session.close()
示例2: main
# 需要導入模塊: import auth [as 別名]
# 或者: from auth import authenticate [as 別名]
def main():
# Please notice that you need to put in your client id and client secret in demo/auth.py in order to make this work.
oauth, _, _ = authenticate()
run_examples(oauth)
os._exit(0)