@@ -109,6 +109,7 @@ def init_store():
109
109
store ['Token' ] = {}
110
110
store ['expires_at' ] = int (0 )
111
111
store ['captcha_token' ] = ''
112
+ store ['session_id' ] = str (uuid .uuid4 ())
112
113
113
114
114
115
# load store from file, initialize store structure if no file exists
@@ -220,14 +221,16 @@ def postHTTP(url: str = '', data: str = '', headers: str = '', cookies: str = ''
220
221
221
222
222
223
def authStage0 () -> str :
224
+ global session_id
223
225
try :
224
- id0 = str (uuid .uuid4 ())
226
+ if not session_id :
227
+ session_id = str (uuid .uuid4 ())
225
228
id1 = str (uuid .uuid4 ())
226
229
ocp = base64 .b64decode (APIKey ).decode ()
227
230
url = 'https://' + api_server + '/eadrax-ucs/v1/presentation/oauth/config'
228
231
headers = {
229
232
'ocp-apim-subscription-key' : ocp ,
230
- 'bmw-session-id' : id0 ,
233
+ 'bmw-session-id' : session_id ,
231
234
'x-identity-provider' : 'gcdm' ,
232
235
'x-correlation-id' : id1 ,
233
236
'bmw-correlation-Id' : id1 ,
@@ -422,6 +425,7 @@ def main():
422
425
global CHARGEPOINT
423
426
global method
424
427
global stateFile
428
+ global session_id
425
429
try :
426
430
method = ''
427
431
CHARGEPOINT = os .environ .get ("CHARGEPOINT" , "1" )
@@ -458,6 +462,9 @@ def main():
458
462
'refresh_token' in store ['Token' ]:
459
463
expires_in = store ['Token' ]['expires_in' ]
460
464
expires_at = store ['expires_at' ]
465
+ if 'session_id' not in store :
466
+ store ['session_id' ] = str (uuid .uuid4 ())
467
+ session_id = store ['session_id' ]
461
468
token = store ['Token' ]
462
469
_exp_at = datetime .fromtimestamp (expires_at ).strftime ('%Y-%m-%d %H:%M:%S' )
463
470
_exp_at2 = datetime .fromtimestamp (expires_at - 120 ).strftime ('%Y-%m-%d %H:%M:%S' )
0 commit comments