-
Notifications
You must be signed in to change notification settings - Fork 549
/
github.html
73 lines (62 loc) · 1.76 KB
/
github.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
70
71
72
73
<!DOCTYPE html>
<link rel="stylesheet" href="/adorn/adorn.css"/>
<script src="/adorn/adorn.js" async></script>
<script src="client_ids.js"></script>
<script src="../src/hello.polyfill.js"></script>
<script src="../src/hello.js"></script>
<script src="../src/modules/github.js"></script>
<title>hello( github )</title>
<h1>hello( github )</h1>
<button id='github' onclick="profile('github');">Get Profile</button>
<script class="pre">
function profile(network) {
var github = hello(network);
github.login().then(function() {
// get user profile data
return github.api('me');
})
.then(function(p) {
document.getElementById(network).innerHTML = "<img src='"+ p.thumbnail + "' width=24/>Connected to "+ network +" as " + p.name;
});
}
</script>
<h2>Get user email</h2>
<button onclick="userEmail('github', 'email');">Get email</button>
<pre id="email"></pre>
<script class="pre">
function userEmail(network, target) {
var github = hello(network)
github.login({
scope:'email'
})
.then(function() {
// Get a bespoke endpoint from github
return github.api('/user/emails');
}).then(function(r) {
document.getElementById(target).innerHTML = JSON.stringify(r, null, 2);
});
}
</script>
<h2>List user repos</h2>
<button onclick="userRepos('github', 'repo_list');">Get a list of repos</button>
<pre id="repo_list"></pre>
<script class="pre">
function userRepos(network, target) {
var github = hello(network)
github.login()
.then(function() {
// Get a bespoke endpoint from github
return github.api('/user/repos');
}).then(function(r) {
document.getElementById(target).innerHTML = JSON.stringify(r, null, 2);
});
}
</script>
<script class="pre">
hello.init({
github : GITHUB_CLIENT_ID
},{
redirect_uri : '../redirect.html',
// oauth_proxy : OAUTH_PROXY_URL
});
</script>