File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ __pycache__/
3
3
* .py [cod ]
4
4
* $py.class
5
5
.idea /*
6
+ .vscode /*
6
7
7
8
# C extensions
8
9
* .so
Original file line number Diff line number Diff line change @@ -261,3 +261,30 @@ def get_auth_header(self):
261
261
auth_header = base64 .b64encode (bytes (self .client_id + ':' + self .client_secret , 'utf-8' )).decode ()
262
262
263
263
return 'Basic ' + auth_header
264
+
265
+ def get_new_access_tokens (self , refresh_token ):
266
+
267
+ headers = {
268
+ 'Accept' : 'application/json' ,
269
+ 'content-type' : 'application/x-www-form-urlencoded' ,
270
+ 'Authorization' : self .get_auth_header ()
271
+ }
272
+
273
+ payload = {
274
+ 'refresh_token' : refresh_token ,
275
+ 'grant_type' : 'refresh_token'
276
+ }
277
+
278
+ response = requests .post (self .access_token_url , data = payload , headers = headers )
279
+ if response .status_code != 200 :
280
+ return response .text
281
+
282
+ bearer_raw = json .loads (response .text )
283
+ self .x_refresh_token_expires_in = bearer_raw ['x_refresh_token_expires_in' ]
284
+ self .access_token = bearer_raw ['access_token' ]
285
+ self .token_type = bearer_raw ['token_type' ]
286
+ self .refresh_token = bearer_raw ['refresh_token' ]
287
+ self .expires_in = bearer_raw ['expires_in' ]
288
+
289
+ if 'id_token' in bearer_raw :
290
+ self .id_token = bearer_raw ['id_token' ]
You can’t perform that action at this time.
0 commit comments