From 8b9dfe0cfb88dee5a8f049221dd51e57aac0bedb Mon Sep 17 00:00:00 2001 From: jdeepee Date: Mon, 16 Apr 2018 21:03:18 +0100 Subject: [PATCH] OAuth object now supports refresh token method to generate a new OAuth token upon expiration of the existing --- clio/client.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/clio/client.py b/clio/client.py index a9c7df0..c6579c4 100644 --- a/clio/client.py +++ b/clio/client.py @@ -166,6 +166,19 @@ def get_token(self, code, redirect_uri): }) return json.loads(urllib.urlopen(api_oauth + '/token', data = post_args).read()) + + def refresh_token(self, refresh_token): + ''' + This method retrieves a new Oauth token using the refresh token + ''' + post_args = urllib.urlencode({ + 'client_id': self.public_key, + 'client_secret': self.private_key, + 'grant_type': 'refresh_token', + 'refresh_token': refresh_token, + }) + return json.loads(urllib.urlopen(api_oauth + 'token', + data = post_args).read()) class _PropClass(object): '''