@@ -109,6 +109,7 @@ def init_store():
109109 store ['Token' ] = {}
110110 store ['expires_at' ] = int (0 )
111111 store ['captcha_token' ] = ''
112+ store ['session_id' ] = str (uuid .uuid4 ())
112113
113114
114115# 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 = ''
220221
221222
222223def authStage0 () -> str :
224+ global session_id
223225 try :
224- id0 = str (uuid .uuid4 ())
226+ if not session_id :
227+ session_id = str (uuid .uuid4 ())
225228 id1 = str (uuid .uuid4 ())
226229 ocp = base64 .b64decode (APIKey ).decode ()
227230 url = 'https://' + api_server + '/eadrax-ucs/v1/presentation/oauth/config'
228231 headers = {
229232 'ocp-apim-subscription-key' : ocp ,
230- 'bmw-session-id' : id0 ,
233+ 'bmw-session-id' : session_id ,
231234 'x-identity-provider' : 'gcdm' ,
232235 'x-correlation-id' : id1 ,
233236 'bmw-correlation-Id' : id1 ,
@@ -422,6 +425,7 @@ def main():
422425 global CHARGEPOINT
423426 global method
424427 global stateFile
428+ global session_id
425429 try :
426430 method = ''
427431 CHARGEPOINT = os .environ .get ("CHARGEPOINT" , "1" )
@@ -458,6 +462,9 @@ def main():
458462 'refresh_token' in store ['Token' ]:
459463 expires_in = store ['Token' ]['expires_in' ]
460464 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' ]
461468 token = store ['Token' ]
462469 _exp_at = datetime .fromtimestamp (expires_at ).strftime ('%Y-%m-%d %H:%M:%S' )
463470 _exp_at2 = datetime .fromtimestamp (expires_at - 120 ).strftime ('%Y-%m-%d %H:%M:%S' )
0 commit comments