From f5b80b6e6340d35f0904370caf624b8a31378dd3 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 23 Jan 2019 08:54:20 -0600 Subject: [PATCH] Remove None values from sig generation --- src/authenticator/official.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/authenticator/official.py b/src/authenticator/official.py index 62772fd..caae14a 100644 --- a/src/authenticator/official.py +++ b/src/authenticator/official.py @@ -28,7 +28,9 @@ def get_sig(method, values, secret): """ Create a signature for parameters passed to VK API. """ postdata = "" for key in values: - postdata = postdata + "{key}={value}&".format(key=key, value=values[key]) + # None values should be excluded from SIG, otherwise VK won't validate it correctly. + if values[key] != None: + postdata = postdata + "{key}={value}&".format(key=key, value=values[key]) # Remove the last "&" character. postdata = postdata[:-1] sig = md5(b"/method/"+method.encode("utf-8")+b"?"+postdata.encode("utf-8")+secret.encode("utf-8"))