Mise à jour de l'authentification

This commit is contained in:
2026-01-07 14:22:50 +01:00
parent 4fe61ebfbc
commit 771fe374fa

View File

@@ -9,12 +9,13 @@ from http.cookiejar import CookieJar
from urllib.parse import urlencode
from urllib.error import HTTPError
from time import time
from json import loads as json_read
authors = (
'Sasha "Almtesh" Évan MOREL',
)
name = 'homesfr pour Python 3'
version = '1.5'
version = '1.6'
# Modes utilisables
MODE_OFF = 0
@@ -37,11 +38,15 @@ base_url = 'https://home.sfr.fr'
# Authentification
auth_path = '/mysensors'
auth_ok_url = 'https://home.sfr.fr/logged'
auth_post_url = 'https://boutique.home.sfr.fr/authentification'
auth_referer = 'https://boutique.home.sfr.fr/authentification?back=service'
auth_post_url = 'https://home.sfr.fr/login'
auth_referer = 'https://home.sfr.fr/login'
auth_user_field = 'email'
auth_pass_field = 'passwd'
auth_extra_fields = {'back': 'service', 'token_sso': '', 'error_sso': '', 'SubmitLogin': 'OK'}
auth_extra_fields = {'back': 'service', 'error_sso': '', 'SubmitLogin': 'OK'}
auth_sso_post_url = 'https://home.sfr.fr/sso-connector.php'
auth_sso_user_field = 'connectionSFR'
auth_sso_pass_field = 'passSFR'
auth_sso_get_field = 'token_sso'
auth_logout_path = '/deconnexion'
# Chemin pour la liste des capteurs
@@ -324,7 +329,19 @@ class HomeSFR ():
'''
if self.username is not None and self.password is not None:
self.opener.open (auth_referer)
data = auth_extra_fields
# SSO
data = {}
data [auth_sso_user_field] = self.username
data [auth_sso_pass_field] = self.password
data = bytes (urlencode (data), 'UTF8')
if self.DEBUG:
print ('Cookies ' + str (len (self.cookies)))
print ('Envoi de ' + str (data))
a = self.opener.open (auth_sso_post_url, data = data)
sso = json_read (a.read ().decode ('UTF8')) ['result']
# Authenfication
data = dict (auth_extra_fields)
data [auth_sso_get_field] = sso [auth_sso_get_field]
data [auth_user_field] = self.username
data [auth_pass_field] = self.password
data = bytes (urlencode (data), 'UTF8')