x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <meta charset="utf-8" />
5
    <title>Advanced authorization form</title>
6
</head>
7
<body>
8
    <p><b>Different parameters in advanced authorization form:</b></p>
9
    <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>.
10
    <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>
11
    </p>
12
    <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.
13
    <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>
14
    <br />
15
    <span id="success"></span>
16
    </p>
17
    <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 />
18
    <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>
19
    </p>
20
</body>
21
</html>
22
HTML
1
 
1
CSS
26
 
1
function openWin(url) {
2
    var win = window.open(url, "_blank", "width=760, height=500, top=300, left=500");
3
}
4
5
// Get token message, which is sent from auth window to parent window when redirect_uri is set to hosting.wialon.com/post_token.html
6
window.onmessage = function (e) {
7
  var msg = e.data;
8
  if (typeof msg == "string" && msg.indexOf("access_token=") >= 0) {
9
    var token = msg.replace("access_token=", "");
10
    var el = document.getElementById("success");
11
    if (el) {
12
        el.innerHTML = "Your token: " + token;
13
    }
14
  }
15
};
16
17
/*
18
19
checker.html - is simple blank page, where authorization form can redirect to with resulting token in url.
20
    Then you can extract token from url and use in your app/site.
21
22
post_token.html - is simple page, where authorization form can redirect to with resulting token in url.
23
    When token recieved this page sends post message with token to parent window. You can get it in your app
24
    by using window.onmessage function.
25
26
*/
JS
Result
Source code of example Close ✕
1
 
1
/*source*/