forked from auth0/auth0.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
69 lines (58 loc) · 2.11 KB
/
test.html
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
<!DOCTYPE html>
<html>
<head>
<title>Auth0.js Demo Examples</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//cdn.auth0.com/js/auth0/development/auth0.min.js"></script>
</head>
<body class="container">
<input id="login-username" value="" />
<input id="login-password" type="password" value="" />
<input id="login-scope" value="" />
<input id="login-response-type" value="" />
<input type="button" class="login-redirect-usernamepassword" value="redirect usernamepassword" />
<input type="button" class="login-redirect-authorize" value="redirect authorize" />
<div id="err"></div>
<div id="result"></div>
<script type="text/javascript">
var webAuth = new auth0.WebAuth({
domain: 'auth0-tests-auth0js.auth0.com',
redirectUri: window.location.href,
clientID: '3GGMIEuBPZ28lb6NBDNARaEZisqFakAs',
leeway: 30
});
$('.login-redirect-usernamepassword').click(function (e) {
e.preventDefault();
webAuth.redirect.loginWithCredentials({
connection: 'tests',
username: $('#login-username').val(),
password: $('#login-password').val(),
scope: $('#login-scope').val(),
responseType: $('#login-response-type').val()
}, function (err) {
$('#err').html(JSON.stringify(err));
});
});
$('.login-redirect-authorize').click(function (e) {
e.preventDefault();
webAuth.authorize({
scope: $('#login-scope').val(),
responseType: $('#login-response-type').val()
});
});
webAuth.parseHash(function (err, result) {
if (err) {
$('#err').html(JSON.stringify(err));
$(document.body).append($('<div id="parsed"></div>'));
}
if (result) {
$('#result').html(JSON.stringify(result));
$(document.body).append($('<div id="parsed"></div>'));
}
});
$( document ).ready(function() {
$(document.body).append($('<div id="loaded"></div>'));
});
</script>
</body>
</html>