mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
32_withings: temporary fix of login function before rewrite
git-svn-id: https://svn.fhem.de/fhem/trunk@14576 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
99eaf99c74
commit
8598d34bff
@ -1,5 +1,6 @@
|
||||
# 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.
|
||||
- bugfix: 32_withings: temporary fix of login function before rewrite
|
||||
- bugfix: 93_DbRep: V5.2.1, bugfix in sqlCmd to support PRAGMA, UTF8
|
||||
- feature: 93_DbLog: V2.17.1, optional UTF-8 support for MySQL database
|
||||
(additional parameter in db.conf neccesary for activation)
|
||||
|
@ -10,7 +10,7 @@
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
# Release 03 / 2017-04-14
|
||||
# Release 04 / 2017-06-25
|
||||
|
||||
package main;
|
||||
|
||||
@ -372,8 +372,8 @@ sub withings_Define($$) {
|
||||
|
||||
$hash->{helper}{username} = $username;
|
||||
$hash->{helper}{password} = $password;
|
||||
$hash->{helper}{appliver} = undef;
|
||||
$hash->{helper}{csrf_token} = undef;
|
||||
$hash->{helper}{appliver} = '9855c478';
|
||||
$hash->{helper}{csrf_token} = '9855c478';
|
||||
} else {
|
||||
return "Usage: define <name> withings ACCOUNT <login> <password>" if(@a < 3 || @a > 5);
|
||||
}
|
||||
@ -519,7 +519,9 @@ sub withings_getSessionKey($) {
|
||||
|
||||
return if( $hash->{SUBTYPE} ne "ACCOUNT" );
|
||||
|
||||
my $resolve = inet_aton("healthmate.withings.com");
|
||||
return if( $hash->{SessionKey} && $hash->{SessionTimestamp} && gettimeofday() - $hash->{SessionTimestamp} < (60*60*24*7-3600) );
|
||||
|
||||
my $resolve = inet_aton("account.health.nokia.com");
|
||||
if(!defined($resolve))
|
||||
{
|
||||
$hash->{SessionTimestamp} = 0;
|
||||
@ -527,67 +529,65 @@ sub withings_getSessionKey($) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
return if( $hash->{SessionKey} && $hash->{SessionTimestamp} && gettimeofday() - $hash->{SessionTimestamp} < (60*60*24*7-3600) );
|
||||
|
||||
$hash->{'.https'} = "https" if(!defined($hash->{'.https'}));
|
||||
|
||||
my $data1;
|
||||
if( !defined($hash->{helper}{appliver}) || !defined($hash->{helper}{csrf_token}) || !defined($hash->{SessionTimestamp}) || gettimeofday() - $hash->{SessionTimestamp} > (30*60) )#!defined($hash->{helper}{appliver}) || !defined($hash->{helper}{csrf_token}))
|
||||
{
|
||||
my($err0,$data0) = HttpUtils_BlockingGet({
|
||||
url => $hash->{'.https'}."://healthmate.withings.com/",
|
||||
timeout => 10,
|
||||
noshutdown => 1,
|
||||
});
|
||||
if($err0 || !defined($data0))
|
||||
{
|
||||
Log3 "withings", 1, "$name: appliver call failed! ".$err0;
|
||||
return undef;
|
||||
}
|
||||
$data1 = $data0;
|
||||
$data0 =~ /appliver=([^.*]+)\&/;
|
||||
$hash->{helper}{appliver} = $1;
|
||||
if(!defined($hash->{helper}{appliver})) {
|
||||
Log3 "withings", 1, "$name: APPLIVER ERROR ";
|
||||
$hash->{STATE} = "APPLIVER error";
|
||||
return undef;
|
||||
}
|
||||
Log3 "withings", 4, "$name: appliver ".$hash->{helper}{appliver};
|
||||
# my $data1;
|
||||
# if( !defined($hash->{helper}{appliver}) || !defined($hash->{helper}{csrf_token}) || !defined($hash->{SessionTimestamp}) || gettimeofday() - $hash->{SessionTimestamp} > (30*60) )#!defined($hash->{helper}{appliver}) || !defined($hash->{helper}{csrf_token}))
|
||||
# {
|
||||
# my($err0,$data0) = HttpUtils_BlockingGet({
|
||||
# url => $hash->{'.https'}."://healthmate.withings.com/",
|
||||
# timeout => 10,
|
||||
# noshutdown => 1,
|
||||
# });
|
||||
# if($err0 || !defined($data0))
|
||||
# {
|
||||
# Log3 "withings", 1, "$name: appliver call failed! ".$err0;
|
||||
# return undef;
|
||||
# }
|
||||
# $data1 = $data0;
|
||||
# $data0 =~ /appliver=([^.*]+)\&/;
|
||||
# $hash->{helper}{appliver} = $1;
|
||||
# if(!defined($hash->{helper}{appliver})) {
|
||||
# Log3 "withings", 1, "$name: APPLIVER ERROR ";
|
||||
# $hash->{STATE} = "APPLIVER error";
|
||||
# return undef;
|
||||
# }
|
||||
# Log3 "withings", 4, "$name: appliver ".$hash->{helper}{appliver};
|
||||
# #}
|
||||
#
|
||||
#
|
||||
# #if( !defined($hash->{helper}{csrf_token}) )
|
||||
# #{
|
||||
# $data1 =~ /csrf_token" value="(.*)"/;
|
||||
# $hash->{helper}{csrf_token} = $1;
|
||||
#
|
||||
# if(!defined($hash->{helper}{csrf_token})) {
|
||||
# Log3 "withings", 1, "$name: CSRF ERROR ";
|
||||
# $hash->{STATE} = "CSRF error";
|
||||
# return undef;
|
||||
# }
|
||||
# Log3 "withings", 4, "$name: csrf_token ".$hash->{helper}{csrf_token};
|
||||
#}
|
||||
|
||||
|
||||
#if( !defined($hash->{helper}{csrf_token}) )
|
||||
#{
|
||||
$data1 =~ /csrf_token" value="(.*)"/;
|
||||
$hash->{helper}{csrf_token} = $1;
|
||||
|
||||
if(!defined($hash->{helper}{csrf_token})) {
|
||||
Log3 "withings", 1, "$name: CSRF ERROR ";
|
||||
$hash->{STATE} = "CSRF error";
|
||||
return undef;
|
||||
}
|
||||
Log3 "withings", 4, "$name: csrf_token ".$hash->{helper}{csrf_token};
|
||||
}
|
||||
|
||||
#my $ua = LWP::UserAgent->new;
|
||||
#my $request = HTTP::Request->new(POST => $hash->{'.https'}.'://account.withings.com/connectionuser/account_login?appname=my2&appliver='.$hash->{helper}{appliver}.'&r=https%3A%2F%2Fhealthmate.withings.com%2F',[email => withings_decrypt($hash->{helper}{username}), password => withings_decrypt($hash->{helper}{password}), is_admin => '',]);
|
||||
#my $get_data = 'use_authy=&is_admin=&email='.uri_escape(withings_decrypt($hash->{helper}{username})).'&password='.uri_escape(withings_decrypt($hash->{helper}{password}));
|
||||
#$request->content($get_data);
|
||||
#my $response = $ua->request($request);
|
||||
|
||||
$resolve = inet_aton("account.withings.com");
|
||||
if(!defined($resolve))
|
||||
{
|
||||
Log3 "withings", 1, "$name: DNS error on getSessionKey.";
|
||||
return undef;
|
||||
}
|
||||
# $resolve = inet_aton("account.health.nokia.com");
|
||||
# if(!defined($resolve))
|
||||
# {
|
||||
# Log3 "withings", 1, "$name: DNS error on getSessionKey.";
|
||||
# return undef;
|
||||
# }
|
||||
|
||||
my $datahash = {
|
||||
url => $hash->{'.https'}."://account.withings.com/connectionuser/account_login?appname=my2&appliver=".$hash->{helper}{appliver}."&r=https%3A%2F%2Fhealthmate.withings.com%2F",
|
||||
url => $hash->{'.https'}."://account.health.nokia.com/connectionwou/account_login?r=https://dashboard.health.nokia.com/",
|
||||
timeout => 10,
|
||||
noshutdown => 1,
|
||||
ignoreredirects => 1,
|
||||
data => { email=> withings_decrypt($hash->{helper}{username}), password => withings_decrypt($hash->{helper}{password}), is_admin => '', csrf_token => $hash->{helper}{csrf_token} },
|
||||
data => { email=> withings_decrypt($hash->{helper}{username}), password => withings_decrypt($hash->{helper}{password}), is_admin => '' },
|
||||
};
|
||||
|
||||
my($err,$data) = HttpUtils_BlockingGet($datahash);
|
||||
@ -612,8 +612,8 @@ sub withings_getSessionKey($) {
|
||||
{
|
||||
$hash->{STATE} = "Cookie error";
|
||||
Log3 "withings", 1, "$name: COOKIE ERROR ";
|
||||
$hash->{helper}{appliver} = undef;
|
||||
$hash->{helper}{csrf_token} = undef;
|
||||
$hash->{helper}{appliver} = '9855c478';
|
||||
$hash->{helper}{csrf_token} = '9855c478';
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user