mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
32_withings: fixed sessionkey retrieval
git-svn-id: https://svn.fhem.de/fhem/trunk@25991 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
3060003402
commit
d0616af97e
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- bugfix: 32_withings: fixed sessionkey retrieval
|
||||||
- bugfix: 70_SVDRP: handle timers with german Umlaute
|
- bugfix: 70_SVDRP: handle timers with german Umlaute
|
||||||
- bugfix: 14_SD_WS09: fixed windDirAverage bug
|
- bugfix: 14_SD_WS09: fixed windDirAverage bug
|
||||||
- bugfix: 95_Dashboard: fix perl warnings, Forum: #127216
|
- bugfix: 95_Dashboard: fix perl warnings, Forum: #127216
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Release 14 / 2020-10-01
|
# Release 16 / 2022-04-24
|
||||||
|
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
@ -528,7 +528,7 @@ sub withings_Define($$) {
|
|||||||
|
|
||||||
$hash->{helper}{username} = $username;
|
$hash->{helper}{username} = $username;
|
||||||
$hash->{helper}{password} = $password;
|
$hash->{helper}{password} = $password;
|
||||||
$hash->{helper}{appliver} = '4080100';
|
$hash->{helper}{appliver} = '5010005';
|
||||||
#$hash->{helper}{csrf_token} = 'e0a2595a83b85236709e366a8eed30b568df3dde';
|
#$hash->{helper}{csrf_token} = 'e0a2595a83b85236709e366a8eed30b568df3dde';
|
||||||
} else {
|
} else {
|
||||||
return "Usage: define <name> withings ACCOUNT <login> <password>" if(@a < 3 || @a > 5);
|
return "Usage: define <name> withings ACCOUNT <login> <password>" if(@a < 3 || @a > 5);
|
||||||
@ -784,6 +784,7 @@ sub withings_getSessionKey($) {
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
|
return undef if(IsDisabled($hash));
|
||||||
return if( $hash->{SUBTYPE} ne "ACCOUNT" );
|
return if( $hash->{SUBTYPE} ne "ACCOUNT" );
|
||||||
|
|
||||||
return if( $hash->{SessionKey} && $hash->{SessionTimestamp} && gettimeofday() - $hash->{SessionTimestamp} < (60*60*24*7-3600) );
|
return if( $hash->{SessionKey} && $hash->{SessionTimestamp} && gettimeofday() - $hash->{SessionTimestamp} < (60*60*24*7-3600) );
|
||||||
@ -850,11 +851,11 @@ sub withings_getSessionKey($) {
|
|||||||
# }
|
# }
|
||||||
|
|
||||||
my $datahash = {
|
my $datahash = {
|
||||||
url => "https://account.withings.com/connectionwou/account_login?r=https://healthmate.withings.com/",
|
url => "https://scalews.withings.net/cgi-bin/auth",
|
||||||
|
method => "POST",
|
||||||
timeout => 10,
|
timeout => 10,
|
||||||
noshutdown => 1,
|
noshutdown => 1,
|
||||||
ignoreredirects => 1,
|
data => { action => 'login', email => withings_decrypt($hash->{helper}{username}), hash => md5_hex(withings_decrypt($hash->{helper}{password})), duration => '604800', os => 'ios', osversion => '15.4', appname => 'wiscaleNG', apppfm => 'ios', appliver => '5010005' },
|
||||||
data => { email=> withings_decrypt($hash->{helper}{username}), password => withings_decrypt($hash->{helper}{password}), is_admin => 'f', use_2fa => '' },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
my($err,$data) = HttpUtils_BlockingGet($datahash);
|
my($err,$data) = HttpUtils_BlockingGet($datahash);
|
||||||
@ -865,12 +866,21 @@ sub withings_getSessionKey($) {
|
|||||||
$hash->{STATE} = "Login error" if( $hash->{SUBTYPE} eq "ACCOUNT" );
|
$hash->{STATE} = "Login error" if( $hash->{SUBTYPE} eq "ACCOUNT" );
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $json = eval { JSON->new->utf8(0)->decode($data) };
|
||||||
|
if($@)
|
||||||
|
{
|
||||||
|
Log3 $name, 2, "$name: json evaluation error on getSessionKey: ".$@;
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($datahash->{httpheader} =~ /session_key=(.*?);/)
|
|
||||||
|
if(defined($json->{body}{sessionid}))
|
||||||
{
|
{
|
||||||
$hash->{SessionKey} = $1;
|
$hash->{SessionKey} = $json->{body}{sessionid};
|
||||||
$hash->{SessionTimestamp} = (gettimeofday())[0] if( $hash->{SessionKey} );
|
$hash->{SessionTimestamp} = (gettimeofday())[0] if( $hash->{SessionKey} );
|
||||||
|
$hash->{Token} = $json->{body}{auth_token} if(defined($json->{body}{auth_token}));
|
||||||
$hash->{STATE} = "Connected" if( $hash->{SessionKey} );
|
$hash->{STATE} = "Connected" if( $hash->{SessionKey} );
|
||||||
$hash->{STATE} = "Session error" if( !$hash->{SessionKey} );
|
$hash->{STATE} = "Session error" if( !$hash->{SessionKey} );
|
||||||
Log3 $name, 4, "$name: sessionkey ".$hash->{SessionKey};
|
Log3 $name, 4, "$name: sessionkey ".$hash->{SessionKey};
|
||||||
@ -879,7 +889,7 @@ sub withings_getSessionKey($) {
|
|||||||
{
|
{
|
||||||
$hash->{STATE} = "Cookie error" if( $hash->{SUBTYPE} eq "ACCOUNT" );
|
$hash->{STATE} = "Cookie error" if( $hash->{SUBTYPE} eq "ACCOUNT" );
|
||||||
Log3 $name, 1, "$name: COOKIE ERROR ";
|
Log3 $name, 1, "$name: COOKIE ERROR ";
|
||||||
$hash->{helper}{appliver} = '4080100';
|
$hash->{helper}{appliver} = '5010005';
|
||||||
#$hash->{helper}{csrf_token} = '9855c478';
|
#$hash->{helper}{csrf_token} = '9855c478';
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -936,6 +946,7 @@ sub withings_connect($) {
|
|||||||
|
|
||||||
$hash->{'.https'} = "https";
|
$hash->{'.https'} = "https";
|
||||||
$hash->{'.https'} = "http" if( AttrVal($name, "nossl", 0) );
|
$hash->{'.https'} = "http" if( AttrVal($name, "nossl", 0) );
|
||||||
|
return undef if(IsDisabled($hash));
|
||||||
|
|
||||||
withings_getSessionKey( $hash );
|
withings_getSessionKey( $hash );
|
||||||
|
|
||||||
@ -1699,8 +1710,8 @@ sub withings_poll($;$) {
|
|||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
RemoveInternalTimer($hash, "withings_poll");
|
RemoveInternalTimer($hash, "withings_poll");
|
||||||
|
|
||||||
return undef if(IsDisabled($name));
|
return undef if(IsDisabled($name));
|
||||||
|
return undef if(IsDisabled($hash->{IODev}));
|
||||||
|
|
||||||
|
|
||||||
#my $resolve = inet_aton("scalews.withings.com");
|
#my $resolve = inet_aton("scalews.withings.com");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user