mirror of https://github.com/veops/cmdb.git
docs: update build_api_key
This commit is contained in:
parent
9ead4e7d8d
commit
06ae1bcf13
|
@ -342,8 +342,8 @@ key = "Your API key"
|
||||||
secret = "Your API secret"
|
secret = "Your API secret"
|
||||||
|
|
||||||
def build_api_key(path, params):
|
def build_api_key(path, params):
|
||||||
values = "".join([str(params[k]) for k in sorted(params.keys())
|
values = "".join([str(params[k]) for k in sorted((params or {}).keys())
|
||||||
if params[k] is not None and not k.startswith('_')]) if params.keys() else ""
|
if k not in ("_key", "_secret") and not isinstance(params[k], (dict, list))])
|
||||||
_secret = "".join([path, secret, values]).encode("utf-8")
|
_secret = "".join([path, secret, values]).encode("utf-8")
|
||||||
params["_secret"] = hashlib.sha1(_secret).hexdigest()
|
params["_secret"] = hashlib.sha1(_secret).hexdigest()
|
||||||
params["_key"] = key
|
params["_key"] = key
|
||||||
|
@ -365,8 +365,8 @@ SECRET = "Your API secret"
|
||||||
|
|
||||||
|
|
||||||
def build_api_key(path, params):
|
def build_api_key(path, params):
|
||||||
values = "".join([str(params[k]) for k in sorted(params.keys())
|
values = "".join([str(params[k]) for k in sorted((params or {}).keys())
|
||||||
if params[k] is not None and not k.startswith('_')]) if params.keys() else ""
|
if k not in ("_key", "_secret") and not isinstance(params[k], (dict, list))])
|
||||||
_secret = "".join([path, SECRET, values]).encode("utf-8")
|
_secret = "".join([path, SECRET, values]).encode("utf-8")
|
||||||
params["_secret"] = hashlib.sha1(_secret).hexdigest()
|
params["_secret"] = hashlib.sha1(_secret).hexdigest()
|
||||||
params["_key"] = KEY
|
params["_key"] = KEY
|
||||||
|
@ -395,8 +395,8 @@ SECRET = "Your API secret"
|
||||||
|
|
||||||
|
|
||||||
def build_api_key(path, params):
|
def build_api_key(path, params):
|
||||||
values = "".join([str(params[k]) for k in sorted(params.keys())
|
values = "".join([str(params[k]) for k in sorted((params or {}).keys())
|
||||||
if params[k] is not None and not k.startswith('_')]) if params.keys() else ""
|
if k not in ("_key", "_secret") and not isinstance(params[k], (dict, list))])
|
||||||
_secret = "".join([path, SECRET, values]).encode("utf-8")
|
_secret = "".join([path, SECRET, values]).encode("utf-8")
|
||||||
params["_secret"] = hashlib.sha1(_secret).hexdigest()
|
params["_secret"] = hashlib.sha1(_secret).hexdigest()
|
||||||
params["_key"] = KEY
|
params["_key"] = KEY
|
||||||
|
|
Loading…
Reference in New Issue