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 @@ -254,3 +254,30 @@ def get_auth_header(self):
254
254
auth_header = base64 .b64encode (bytes (self .client_id + ':' + self .client_secret , 'utf-8' )).decode ()
255
255
256
256
return 'Basic ' + auth_header
257
+
258
+ def get_new_access_tokens (self , refresh_token ):
259
+
260
+ headers = {
261
+ 'Accept' : 'application/json' ,
262
+ 'content-type' : 'application/x-www-form-urlencoded' ,
263
+ 'Authorization' : self .get_auth_header ()
264
+ }
265
+
266
+ payload = {
267
+ 'refresh_token' : refresh_token ,
268
+ 'grant_type' : 'refresh_token'
269
+ }
270
+
271
+ response = requests .post (self .access_token_url , data = payload , headers = headers )
272
+ if response .status_code != 200 :
273
+ return response .text
274
+
275
+ bearer_raw = json .loads (response .text )
276
+ self .x_refresh_token_expires_in = bearer_raw ['x_refresh_token_expires_in' ]
277
+ self .access_token = bearer_raw ['access_token' ]
278
+ self .token_type = bearer_raw ['token_type' ]
279
+ self .refresh_token = bearer_raw ['refresh_token' ]
280
+ self .expires_in = bearer_raw ['expires_in' ]
281
+
282
+ if 'id_token' in bearer_raw :
283
+ self .id_token = bearer_raw ['id_token' ]
You can’t perform that action at this time.
0 commit comments