ageof / MyDlink-API-Python

MyDlink Cloud Python API
GNU General Public License v3.0
26 stars 5 forks source link

Wrong username/password combination #11

Closed Novivy closed 2 years ago

Novivy commented 2 years ago

I'm porting your client to PHP but i'm stuck on the /oauth/authorize2 call.

I get the error Wrong username/password combination from dlink api.

My payload seems ok because dlink api would return Invalid field format. or Error validating this request if it wasn't..

I have double checked my login/password, i even changed it twice on the dlink website.

This is the url generated by my script :

https://api.auto.mydlink.com/oauth/authorize2?client_id=mydlinkuapandroid&redirect_uri=https%3A%2F%2Fmydlink.com&user_name=myemail%40gmail.com&password=MydlinkPassword&response_type=token&timestamp=1647437120&uc_id=bd36a6c011f1287e&uc_name=Yo&sig=70f951989671a71259928cb1d8ad5e15

define('OAUTH2_CLIENT_ID', 'mydlinkuapandroid');
define('OAUTH2_CLIENT_SECRET', '5259311fa8cab90f09f2dc1e09d2d8ee');
define('OAUTH2_ANDROID_ID', 'bd36a6c011f1287e');

$params = [
    'client_id' => OAUTH2_CLIENT_ID,
    'redirect_uri' => 'https://mydlink.com',
    'user_name' => 'myemail@gmail.com',
    'password' => 'MydlinkPassword',
    'response_type' => 'token',
    'timestamp' => time(),
    'uc_id' => OAUTH2_ANDROID_ID,
    'uc_name' => "Yo",

];

$build = http_build_query($params);
$build .= '&sig=' . md5('/oauth/authorize2?' . $build . OAUTH2_CLIENT_SECRET);

$url = 'https://api.auto.mydlink.com/oauth/authorize2?' . $build;

$headers = [];
$headers[] = 'User-Agent: Mozilla/5.0';
$headers[] = 'connection: Keep-Alive';
$headers[] = 'accept: */*';
$headers[] = 'x-md-lang: de';
$headers[] = 'x-md-app-ver: 02.00.01.75';
$headers[] = 'x-md-os-type: android';
$headers[] = 'x-md-os-version: 7.0';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$return = curl_exec($ch);
var_dump($return);

print curl_error($ch);
curl_close($ch);
Novivy commented 2 years ago

I didn't read your code correctly, i had to md5 the password, my bad