Toggle navigation
Wialon Playground
Add library
jQuery latest
Bootstrap 3.3.1
Wialon Javascript SDK
Run
Get code
Fork
Save
Examples
Login
Get units
Change unit icon
Get messages
Get sensors
Edit sensors
Commands
Monitoring notification
Track layer
Get resources
Resources and accounts
Account parameters
Do payment
Management Driver
Create notification
Get geofences
Geofence parameters
Create geofence
Gurtam map
Units on map
Unit trace
Create report template
Execute report
Execute custom report
Create driver
Bind driver to unit
Unit edit fields
Import fillings
Token login for site
Advanced authorization form
Token usage in app
Account hierarchy
Nearest units
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Advanced authorization form</title> </head> <body> <p><b>Different parameters in advanced authorization form:</b></p> <p>Authorize for application <b>Test</b>, with access level - <b>full access</b>, activation time - <b>immediately</b>, duration - <b>one day</b>, <b>return user name</b> in result, <b>redirect to checker.html</b>. <a href="https://hosting.wialon.com/login.html?client_id=myApp&access_type=0xffff&activation_time=0&duration=86400&flags=0x1&redirect_uri=https://hosting.wialon.com/checker.html" onClick="openWin(this.href); return false;"><br />Test >>></a> </p> <p>Authorize for application <b>myApp</b>, with access level - <b>online tracking only</b>, activation time - <b>immediately</b>, duration - <b>one week</b>, <b>return user name</b> in result, <b>redirect to post_token.html</b>, and show token on this page. <a href="https://hosting.wialon.com/login.html?client_id=myApp&access_type=0x100&activation_time=0&duration=604800&flags=0x1&redirect_uri=https://hosting.wialon.com/post_token.html" onClick="openWin(this.href); return false;"><br />Test >>></a> <br /> <span id="success"></span> </p> <p>Authorize for application <b>wialon</b>, with access level - <b>full access</b>, activation time - <b>immediately</b>, duration - <b>one month</b>, <b>redirect to this form</b>.<br /> <a href="https://hosting.wialon.com/login.html?client_id=wialon&access_type=-1&activation_time=0&duration=2592000" onClick="openWin(this.href); return false;">Test >>></a> </p> </body> </html>
HTML
CSS
function openWin(url) { var win = window.open(url, "_blank", "width=760, height=500, top=300, left=500"); } // Get token message, which is sent from auth window to parent window when redirect_uri is set to hosting.wialon.com/post_token.html window.onmessage = function (e) { var msg = e.data; if (typeof msg == "string" && msg.indexOf("access_token=") >= 0) { var token = msg.replace("access_token=", ""); var el = document.getElementById("success"); if (el) { el.innerHTML = "Your token: " + token; } } }; /* checker.html - is simple blank page, where authorization form can redirect to with resulting token in url. Then you can extract token from url and use in your app/site. post_token.html - is simple page, where authorization form can redirect to with resulting token in url. When token recieved this page sends post message with token to parent window. You can get it in your app by using window.onmessage function. */
JS
Result
Source code of example
Close ✕
×
Source code