Comments on: How to authenticate to TP-Link cloud API http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/ Blog about Cloud, Automation, Android, Smart things... Thu, 27 Jul 2017 22:01:00 +0000 hourly 1 https://wordpress.org/?v=4.7.5 By: Richard Nardone http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/#comment-222 Tue, 25 Jul 2017 11:50:00 +0000 http://itnerd.space/?p=345#comment-222 The issue was using ajax shorthand ($.post). With shorthand you can’t specify the content-type. The “json” at the end of the code just specifies how you want the data result formatted (Accept Header). Once I updated the code to the following I was able to specify the content-type and retrieve the token without error:

$.ajax({
type: ‘POST’,
contentType: “application/json”,
url: myURL,
data: myData,
dataType: “json”,
success: function(data, status) {
$(‘#result-data’).append(JSON.stringify(data));
$(‘#result-status’).append(status);
$(‘#result-token’).append(data.result.token);
}
});

My new result is:
{“error_code”:0,”result”:{“regTime”:”2016-10-23 23:45:58″,”email”:”[email protected]”,”token”:”00xxx111-x1234b45cd6e7fghij89k0l”}}

My “Success” data is being appended to DIV layers for testing purposes:

]]>
By: Alexandre Dumont http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/#comment-221 Tue, 25 Jul 2017 05:23:00 +0000 http://itnerd.space/?p=345#comment-221 Try to force the header ‘Content-Type: application/json’, and remove the “json” you specified.

]]>
By: Richard Nardone http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/#comment-220 Mon, 24 Jul 2017 23:28:00 +0000 http://itnerd.space/?p=345#comment-220 I created a script to get my token but I keep getting a format error.

Code:
$.post(“https://use1-wap.tplinkcloud.com”,
{
method: “login”,
params: {
appType: “Kasa_Android”,
cloudUserName: “[email protected]”,
cloudPassword: “SimplePasswordLettersandNumbers”,
terminalUUID: “b6085622-86e0-4940-8fd3-4b60862de994”
}
},
function(data,status) {
$(‘#result-data’).append(JSON.stringify(data));
$(‘#result-status’).append(status);
}, “json” );

The above code returns error:
{“error_code”:-10100,”msg”:”JSON format error”}

Anyone know what I’m doing wrong?

]]>
By: Alexandre Dumont http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/#comment-201 Tue, 18 Jul 2017 13:15:00 +0000 http://itnerd.space/?p=345#comment-201 Amazing Richard. I’m glad it worked for you. Enjoy your smartplugs.

]]>
By: Richard http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/#comment-200 Tue, 18 Jul 2017 12:51:00 +0000 http://itnerd.space/?p=345#comment-200 Your other post describing how to get the list of devices gave me the correct device IDs and it is now working. Thank you for the quick reply!

]]>
By: Alexandre Dumont http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/#comment-199 Tue, 18 Jul 2017 12:33:00 +0000 http://itnerd.space/?p=345#comment-199 To easily identify the DevideID of each plug, within the Kasa app, give a name to each plug. Then use the method shown here http://itnerd.space/2017/05/21/how-to-get-the-tp-link-hs100-cloud-end-point-url to list all your devices. You’ll see the Alias and the corresponding Device ID of each plug.

Regarding the rate limiting, I guess it’s something to do with IFTTT.

]]>
By: Richard http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/#comment-198 Tue, 18 Jul 2017 11:10:00 +0000 http://itnerd.space/?p=345#comment-198 I have 3 of these plugs so I switched 2 of them off at the wall I wasn’t sure how to identify the device ID for each plug. With a single plug switched on, I followed the instructions exactly on your post of how to control via IFTTT and tried basic triggers of email sent from Gmail/Contact added to Gmail just to test it but neither of these worked.

Any idea what I could be doing wrong?

EDIT: If I open the IFTTT app, the Activity shows ‘Usage limit exceeded’. If I click into the detail, it states ‘User Rate Limit Exceeded’

]]>
By: Alexandre Dumont http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/#comment-192 Sun, 16 Jul 2017 21:06:00 +0000 http://itnerd.space/?p=345#comment-192 Hum… I don’t have Alexa myself, so I can’t confirm. Others here might have it, hopefully they can help.

]]>
By: Joe H http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/#comment-191 Sat, 15 Jul 2017 12:28:00 +0000 http://itnerd.space/?p=345#comment-191 Great work finding out how to get a token!
I’m having a problem when I go to use the returned token though, always get: {“error_code”:-20651,”msg”:”Token expired”}
When I use it.
I’ve tried seeing whether there’s a time delay or something, but it doesn’t seem to matter how quick you are, it always says expired. Dunno whether having the Alexa skill connected makes a difference or something.
Anyone else having the same problem?

]]>
By: Ben Nikula http://itnerd.space/2017/06/19/how-to-authenticate-to-tp-link-cloud-api/#comment-190 Thu, 13 Jul 2017 19:29:00 +0000 http://itnerd.space/?p=345#comment-190 I think that was it, actually! I escaped “/” and “”, and it worked. Thanks! Now onto the rest of the process…

]]>