Generate the token

Instance URL:
Should be a valid url (with http://).
Client ID:
Client ID is required.
Client Secret:
Client Secret is required.
Redirect URI:
Redirect uri should be valid.
Instance Username
Username is required.
Instance Password
Password is required.
Output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Fedena API</title>
        <script src="https://s3.amazonaws.com/api_play/src/js/jquery-2.1.1.min.js"></script>
        <script src="https://s3.amazonaws.com/api_play/src/js/vkbeautify.0.99.00.beta.js"></script>
        <script>
            $(function() {
                $("#generate-button").click(function() {
                    var fedena_server = $("#fedena_server").val();
                    var client_id = $("#client_id").val();
                    var client_secret = $("#client_secret").val();
                    var redirect_uri = $("#redirect_uri").val();
                    var username = $("#username").val();
                    var password = $("#password").val();
                    var token_input = $("#token");
                    var result_div = $("#result");
                    generate_token(fedena_server,client_id,client_secret,redirect_uri,username,password, token_input,result_div);
                });
            });
        </script>
        <script>
            function generate_token(fedena_server,client_id,client_secret,redirect_uri,username,password, token_input,result_div){
                token_input.val("");
                result_div.html("");
                try
                {
                    var xhr = new XMLHttpRequest();
                    xhr.open("POST", fedena_server+"/oauth/token", true);
                    xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
                    xhr.onreadystatechange=function(e)
                    {
                        if (xhr.readyState==4)
                        {
                            var a=JSON.parse(e.target.responseText);
                            token_input.val(a["access_token"])
                            result_div.html(show_response(e.target.responseText));
                        }
                    }
                    xhr.send("client_id="+client_id+"&client_secret="+client_secret+"&grant_type=password&username="+username+"&password="+password+"&redirect_uri="+redirect_uri);
                }
                catch(err)
                {
                    alert(err.message);
                }
            }

            function show_response(str){
                str = vkbeautify.xml(str,4); /* Optional, To format the XML output*/
                return str.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g,"<br />");
            }

        </script>
    </head>
    <body>
        <h3> Generate the token </h3>
        <div>
            <table>
                <tr>
                    <td>
                        Instance URL:
                    </td>
                    <td>
                        <input id="fedena_server" type="text" placeholder="ex: http://myschoolsis.com" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Client ID:
                    </td>
                    <td>
                        <input id="client_id" type="text" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Client Secret:
                    </td>
                    <td>
                        <input id="client_secret" type="text" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Redirect URI:
                    </td>
                    <td>
                        <input id="redirect_uri" type="text" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Instance Username
                    </td>
                    <td>
                        <input id="username" type="text" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Instance Password
                    </td>
                    <td>
                        <input id="password" type="password" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Token
                    </td>
                    <td>
                        <input id="token" type="text" readonly="readonly" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <button type="submit" id="generate-button"> Generate Token </button>
                    </td>
                </tr>
            </table>
            <pre> <code id="result" style="text-align: left; float: left;"></code></pre>
        </div>
    </body>
</html>
loading..