Custom Widget and RESTful TagoIO API

Custom Widget and RESTful TagoIO API

Hello People!

I have tried to use the RESTful TagoIO API with Javascript inside an Custom Widget, when i get info from an device, it works fine in the first time, but when i try to get data, i receive "Invad Token" or "Authorization denied", and when i back to get info like the first time, i still receive "Authorization denied".

How can i solve this? Or better, which is the correct way? I follow the examples in , and i am using the correct device-token to consume the API. My HTML test page:

<!DOCTYPE html>
        <title>Custom Widget</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script type="text/javascript" src=""></script>
        <link rel="stylesheet" type="text/css" href="">  
        <div id="main" >
            <div id="header" ></div>
            <div id="bodyContent" style="overflow: auto; width: 90%; display: inline; white-space: normal;" ></div>
            <div id="foot" ></div>

            window.TagoIO.onStart((widget) => {
                window.widget = widget;

                let token_device_custom =
           (item) => { if(item.key === 'device_custom') return item.value; } );    


                    let myHeaders = new Headers();
                    myHeaders.append("device-token", token_device_custom);

                    let requestOptions = {
                        method: 'GET',
                        headers: myHeaders,
                        redirect: 'follow'

                    fetch("", requestOptions)
                    .then(response => response.text())
                    .then(result => {
                        let objResult = JSON.parse(result);

                        bodyContent.innerHTML = result; //;
                    .catch(error => bodyContent.innerHTML = 'error: ' + error);


                //bodyContent.innerHTML = JSON.stringify(widget.display);



        Take a look at our updated roadmap here!
          What would you like to see on TagoIO?