Need help for beginner..

1,013 views
Skip to first unread message

Amila Indrajith

unread,
Jan 16, 2017, 6:34:03 AM1/16/17
to Wireless Sensor Tags
I'm new to the Wireless tags. I need to access the data using API.

 I can't understand this procedure "http://wirelesstag.net/eth/oauth2_apps.html"

please help me.

Regards,
Amila

Pete

unread,
Jan 16, 2017, 10:56:57 AM1/16/17
to Wireless Sensor Tags
I'll assume that this is just for tinkering and you're not actually developing an application that will interface with the tags.  There are 4 pieces of information that we need to get
  • Client ID
  • Client Secret
  • Code
  • Access Token - this is the value that you will be passing to the server with each API call
So here's how you get all of those pieces: 
  1. Go to http://wirelesstag.net/eth/oauth2_apps.html
  2. Fill out the info in the "Register a new app" section
    • You only need to provide a "Display Name"
    • Click "Create", the section will change and you will now see your unique Client ID and Client Secret
    • Save those, you will need them later, but you can always get back to them by accessing the link in step 1.
  3. Now we need to form a URL using the Client ID
  4. Paste your newly created URL into your web browser
    • If you formed your URL correctly, you will see a page that asks to "Grant API Access to [your app name]?"
  5. Click the "Grant Access" button
  6. At this point, you will get a server error "403 - Forbidden: Access is denied."  Relax, this is normal.
  7. Put your cursor in the address box of the web browser and inspect the URL, inside you will find your 3rd piece of information...the "Code"
  8. Now we need to run the following cURL command, inserting your 3 unique values.  I'm on a Mac and I run this line in Terminal.  On Windows, you may need to install the cURL command line tool in order to run this.
    • curl -X POST https://www.mytaglist.com/oauth2/access_token.aspx -d 'client_id=[client ID of your app]&client_secret=[client secret of your app]&code=[code given in step 2]'
    • Using my fake values in the previous steps, it would look like: curl -X POST https://www.mytaglist.com/oauth2/access_token.aspx -d 'client_id=92bb1001-jeje-8c8c-k4oi-999hh55kk99l&client_secret=123a0a5b-f123-45b6-7nn5-m80890bb9090&code=1234ab56-7c8d-90e1-f23g-4hi56jklm78n'
    • If successful, the server will return a line:  access_token=[access token]   ...SAVE THIS VALUE

  9. Now you're ready to call an API using your access token.  This is the example they provide:
  10. For any of the API that "requires login", you'll need to pass the access token in similar fashion.  However, there are some API that do not require the access token.

T Jakab

unread,
Jan 16, 2017, 11:32:13 AM1/16/17
to Wireless Sensor Tags
Oauth is a standard authorization protocol, not specific to WST. You can find lots of information about it.

And most importantly, many programming languages have supporting libraries so one wouldn't have to implement from scratch.

Amila Indrajith

unread,
Jan 17, 2017, 3:32:21 AM1/17/17
to Wireless Sensor Tags
Thanx for the help.You saved me.

Amila Indrajith

unread,
Jan 17, 2017, 6:52:31 AM1/17/17
to Wireless Sensor Tags
I got the Access Token as you said. I need to pull data from servers one by one. I tried the example what you gave me. How can I change the device? 

Pete

unread,
Jan 17, 2017, 12:00:38 PM1/17/17
to Wireless Sensor Tags
The example "id:1" is for device 1.  You just need to change the value "id:2", "id:3", etc.  

I pull data for all tags in one go with the following:
curl --silent -X POST -H "host: mytaglist.com" -H "Content-Type: application/json; charset=utf-8" -H "Authorization: bearer [access token]" -H "d: """ -H "Cache-Control: no-cache" -d '' "http://mytaglist.com/ethClient.asmx/GetTagList"



If your tag manager is hosted on my.wirelesstag.net, then you might want to change "host: mytaglist.com" to "host: my.wirelesstag.net"

Amila Indrajith

unread,
Jan 18, 2017, 11:41:41 AM1/18/17
to Wireless Sensor Tags
It worked. Thanx. I simply need to check whether some person is in the room or not my plan is to set one of these sensors in the door. How can I do this? Can I use this curl cmnd to do this?

Zhiheng Cao

unread,
Jan 18, 2017, 8:43:30 PM1/18/17
to Amila Indrajith, Wireless Sensor Tags
To check if someone is in a room or not, you will need the PIR
(infra-red) sensor. The door sensor won't be suitable as you don't
know if the person is opening door to leave the room or enter the
room.
> --
> You received this message because you are subscribed to the Google Groups
> "Wireless Sensor Tags" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to wireless-sensor-...@googlegroups.com.
> To post to this group, send email to wireless-s...@googlegroups.com.
> Visit this group at https://groups.google.com/group/wireless-sensor-tags.
> For more options, visit https://groups.google.com/d/optout.

Amila Indrajith

unread,
Jan 20, 2017, 10:49:48 AM1/20/17
to Wireless Sensor Tags, anjelde...@gmail.com
ok. I'll use PIR sensor but how can I pull that open or close state of the door using curl command

T Jakab

unread,
Jan 20, 2017, 11:16:11 AM1/20/17
to Wireless Sensor Tags, anjelde...@gmail.com
Did you try the samples here?

There's one you can edit online.

You can also capture the update calls from the web interface after you log in to your account.
F12 in Chrome, open Network tab.

Wouldn't a Kumo app be better? What exactly do you want to achieve?

Amila Indrajith

unread,
Jan 21, 2017, 10:50:31 PM1/21/17
to Wireless Sensor Tags, anjelde...@gmail.com
yes. I checked that example but changing UUID didn't help me to get temp from my tags.

Pete

unread,
Jan 22, 2017, 1:30:04 AM1/22/17
to Wireless Sensor Tags
Use GetTagListForSlaveId.  Just pass the slaveid (id of the tag: 1,2,3 etc.  This is NOT UUID) and then parse the returned json string.  Temperature is labeled "temperature" and is returned in Celsius so you'll have to convert it if you want Fahrenheit.

curl --silent -X POST http://www.mytaglist.com/ethClient.asmx/GetTagForSlaveId -d '{slaveid:2}' -H 'Content-Type: application/json' -H 'Authorization: Bearer [access token]'


Amila Indrajith

unread,
Jan 22, 2017, 2:22:49 AM1/22/17
to Wireless Sensor Tags
Thanx pete. It worked. When I send this command It gives many details about the tag. I assume this eventstate is the one which I can see whether a motion is detected or not. Correct me if I'm wrong. I see it's changing into 5 when no motion in the around and It's changing into 6 when it detected something.

Pete

unread,
Jan 22, 2017, 2:37:26 AM1/22/17
to Wireless Sensor Tags
Correct.

0=Disarmed,1=Armed,2=Moved,3=Opened,4=Closed,5=DetectedMovement,6=TimedOut




Amila Indrajith

unread,
Jan 22, 2017, 2:42:05 AM1/22/17
to Wireless Sensor Tags
Thanx pete. I appreciate your help. I think I got what I need.Thanx for all who helped me here.

On Sunday, January 22, 2017 at 1:07:26 PM UTC+5:30, Pete wrote:
Correct.

0=Disarmed,1=Armed,2=Moved,3=Opened,4=Closed,5=DetectedMovement,6=TimedOut




Amila Indrajith

unread,
Jan 22, 2017, 3:13:00 AM1/22/17
to Wireless Sensor Tags
Again I got into trouble.I tried to do ajax call for above curl command but it didn't work.This is how I did it.

$.ajaxSetup({
type: "POST",
contentType: "application/json; charset=utf-8",
cache: false,
dataType: "json",
xhrFields: {
withCredentials: true
}
});

        data: JSON.stringify({slaveid:'3'}),
        success: function (data, status) {
        console.log("The returned data", data);
            $("#displayx").text(data);
        },
        error: function (xhr, textStatus, exception) {
            alert(textStatus);
        },
         beforeSend: function(xhr, settings) { xhr.setRequestHeader('Authorization','Bearer ' + 'd960d2a8-cc21-4bef-bc90-890fef9a7572'); }
       });

Devon Croll

unread,
Sep 28, 2017, 4:05:32 AM9/28/17
to Wireless Sensor Tags
Hi Pete

Sorry to cover old ground but I seem to fall at the last hurdle..

I get the client ID, Secret, Code. try to run the Curl command and get the following:

{ "errors": [{ "message": "Object reference not set to an instance of an object." }]}


Cant seem to find anyone else having this problem so must be making a simple mistake but cant seem to figure out what it is.

Any ideas??

Pete

unread,
Sep 28, 2017, 9:33:09 AM9/28/17
to Wireless Sensor Tags
Can you post your cURL command (removing the sensitive parts)?  It might just be a typo but hard to tell without seeing it.

-Pete

Devon Croll

unread,
Sep 30, 2017, 5:46:09 AM9/30/17
to Wireless Sensor Tags
Thanks Pete

Here is the command. I changed a couple of numbers here and there. I hope it is a typo but just copied and pasted from your notes above, then from the notes that appeared at the bottom of the http://wirelesstag.net/eth/oauth2_apps.html page.



curl -X POST https://www.mytaglist.com/oauth2/access_token.aspx -d 'client_id=f4f72343-55ee-4f72-9401-c5b4748c8e50&client_secret=ae11922b-a510-4138-bd8c-d1bf24cf72c6&code=b1c6b9e9-c3a2-4200-9ffc-db4ff7681b17'

Devon Croll

unread,
Oct 1, 2017, 9:24:10 PM10/1/17
to Wireless Sensor Tags
Hi Pete. I’m assuming their was nothing obvious there? I tried again today and still same error. Not looking good for me to add wireless tags into my openHAB if I fail at step one.

Cheers

Devon

Pete

unread,
Oct 2, 2017, 10:39:03 AM10/2/17
to Wireless Sensor Tags
I was out of town over the weekend.  That error is most likely due to one of the 3 pieces of information being incorrect.  Try again from the beginning and make sure the Client ID, Client Secret and Code are correct.  Otherwise, syntax looks fine.


Abdul Rehman

unread,
Oct 8, 2017, 12:08:01 AM10/8/17
to Wireless Sensor Tags
Dear All,
I am also a beginner. I am try to follow Mr. Pete guide but I couldn't download cURL, every time when I download cURL that says this version is not compatible with this machine. Even though my operating system is also 64bit widow 10 but that is not working. Please help me how I can download cURL and how I run curl -X POST if that is not being downloaded.
Thanks

Tibor Jakab-Barthi

unread,
Oct 8, 2017, 12:59:31 PM10/8/17
to Wireless Sensor Tags
You can use any tool what can do HTTP POST and GET. 
E.g. Advanced REST client in Chrome:

Abdul Rehman

unread,
Oct 10, 2017, 11:44:13 PM10/10/17
to Wireless Sensor Tags
Thanks for your reply. I tried this method but this gives, 400 Bad request.

Rod Laird

unread,
Oct 11, 2017, 1:57:47 AM10/11/17
to Wireless Sensor Tags

I get the same error using the Chrome REST client...





Rod Laird

unread,
Oct 11, 2017, 2:16:57 AM10/11/17
to Wireless Sensor Tags
btw I put the following in the request line for REST: https://www.mytaglist.com/oauth2/access_token.aspx -d 'client_id=[client ID of your app]&client_secret=[client secret of your app]&code=[code given in step 2]'
and selected POST and submitted. Also tried separating the data (-d 'xxxx') to the raw payload part of REST - clearly an act of desperation (and no RTFM) - so did not work. Gave error Value cannot be null. Parameter name: g

Also tried in curl, which I had no trouble running - also did not work. Though different error (actually very similar to the separated data REST attempt viz: a header of Value cannot be null. Parameter name: g.
And the following html text 

[ArgumentNullException]: Value cannot be null.
Parameter name: g
   at System.Guid..ctor(String g)
   at MyTagList.oauth2.access_token1.Page_Load(Object sender, EventArgs e) in C:\z560_backup\MyTagList\MyTagList\oauth2\access_token.aspx.cs:line 24
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
[HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown.
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

T Jakab

unread,
Oct 11, 2017, 4:55:45 AM10/11/17
to Wireless Sensor Tags
-d is a flag for curl, is not needed and is not understood by other tools.

In ARC you can switch to Data Form instead of raw payload and enter parameters there. 
If it doesn't change Content-Type to application/x-www-form-urlencoded you'll have to do it manually.
Raw payload would be:
client_id=[client ID of your app]&client_secret=[client secret of your app]&code=[code given in step 2]

I assume the placeholders were replaced with real values.

The top text box should only contain the URL, e.g. https://www.mytaglist.com/oauth2/access_token.aspx.


--
You received this message because you are subscribed to a topic in the Google Groups "Wireless Sensor Tags" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wireless-sensor-tags/OSQeLHsE4W8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wireless-sensor-tags+unsub...@googlegroups.com.
To post to this group, send email to wireless-sensor-tags@googlegroups.com.
parameters.png

Abdul Rehman

unread,
Oct 12, 2017, 12:21:52 AM10/12/17
to Wireless Sensor Tags
I got the access token successfully with this method. 
Capture.PNG

Rod Laird

unread,
Oct 12, 2017, 12:33:36 AM10/12/17
to Wireless Sensor Tags
Thanks that did it - had all correct but the content type!
To post to this group, send email to wireless-s...@googlegroups.com.

Rod Laird

unread,
Oct 12, 2017, 6:48:31 PM10/12/17
to Wireless Sensor Tags
Hi Peter,

I am trying to use Wireless Tags in Stringify and am finding myself frustrated. Stringify does not handle data returns > 512 characters. even using GetTagListForSlaveId the payload is some 830 characters... Is there any way to specify what parameter you want to extract to minimise the return? I cannot see anything in the API spec, so I suspect I am, in the Aussie venacular, "up sh1t creek without a paddle"...

Pete

unread,
Oct 13, 2017, 10:48:40 AM10/13/17
to Wireless Sensor Tags
I'm don't believe there's any API that would allow you to just request a single piece of info from the tag.

Zhiheng Cao

unread,
Oct 13, 2017, 4:55:51 PM10/13/17
to Pete, Wireless Sensor Tags
If you are talking about JSON.stringify, you can easily reduce the length by 
delete obj.[the name of the property]

for example 
>var obj={name:'aaa', comment:'bbb'}
> obj
< {name: "aaa", comment: "bbb"} 
> delete obj.comment
> JSON.stringify(obj)
< "{\"name\":\"aaa\"}" 

On Fri, Oct 13, 2017 at 7:48 AM, Pete <pe...@pete-sandy.com> wrote:
I'm don't believe there's any API that would allow you to just request a single piece of info from the tag.

--
You received this message because you are subscribed to the Google Groups "Wireless Sensor Tags" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wireless-sensor-tags+unsub...@googlegroups.com.
To post to this group, send email to wireless-sensor-tags@googlegroups.com.
Message has been deleted

Annal Chandra

unread,
Jan 24, 2018, 4:15:08 AM1/24/18
to Wireless Sensor Tags
Currently the OAuth tool seems to be broken
No matter what I do, i get "Client ID xxxxx-xxx-xxx is not valid" in step 3 of your example.
Several people have posted the same query on the wirelesstag help site. No solution has been posted.

Pete

unread,
Jan 24, 2018, 9:19:58 AM1/24/18
to Wireless Sensor Tags
I just tested again - following the instructions I posted above - and everything is working fine for me.  I am able to get though each step successfully and end up with an access_token.

Domen

unread,
Nov 5, 2018, 8:03:09 AM11/5/18
to Wireless Sensor Tags
 I did try to connect, but I get error

[ArgumentNullException]: Value cannot be null.
Parameter name: g
   at System.Guid..ctor(String g)
   at MyTagList.oauth2.access_token1.Page_Load(Object sender, EventArgs e) in C:\z560_backup\MyTagList\MyTagList\oauth2\access_token.aspx.cs:line 24
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
[HttpUnhandledException]: Exception of type &#39;System.Web.HttpUnhandledException&#39; was thrown.
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I have Client ID, secret and code

What could be the problem?

Pete

unread,
Nov 8, 2018, 9:49:54 AM11/8/18
to Wireless Sensor Tags
Are you on a Mac, Windows machine, or other?  I assume you're on the step the POST step that I used a cURL command to complete?

Domen

unread,
Nov 8, 2018, 10:39:41 AM11/8/18
to Wireless Sensor Tags
Thanks for replay and hint.

When you did ask for machine I did change ' to " in curl call - because i am on Windows machine. And it worked. In Postman I did have parameters in header instead in body. When I did change that it also did start to work.
Reply all
Reply to author
Forward
0 new messages