From c71a1fbeb501a472cebf0c42f7e1b23bc74b70c4 Mon Sep 17 00:00:00 2001 From: Jacinda Shelly Date: Sat, 12 May 2012 16:57:42 -0400 Subject: [PATCH] Fix for issue #7 - TypeError: Incorrect padding; https://github.com/heroku/facebook-template-python/issues/7 --- exampleapp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exampleapp.py b/exampleapp.py index 4c1becd..8a120a3 100644 --- a/exampleapp.py +++ b/exampleapp.py @@ -131,7 +131,8 @@ def get_token(): encoded_data = c.split('.', 2) sig = encoded_data[0] - data = json.loads(urlsafe_b64decode(str(encoded_data[1]))) + data = json.loads(urlsafe_b64decode(str(encoded_data[1]) + + (64-len(encoded_data[1])%64)*"=")) if not data['algorithm'].upper() == 'HMAC-SHA256': raise ValueError('unknown algorithm {0}'.format(data['algorithm']))