-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallback.html
52 lines (49 loc) · 1.51 KB
/
callback.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
<!DOCTYPE html>
<html>
<head>
<meta name="application-name" content="snow white">
<meta name="generator" content="wang pin">
<meta name="description" content="OAuth github test">
<meta name="keywords" content="HTML,CSS,XML,JavaScript">
<meta name="author" content="wang pin">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--HTML4 charset def-->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--HTML5 charset def-->
<meta charset="UTF-8">
<link rel="icon" href="/assets/icon.ico" type="image/x-icon">
<title>OAuth github test</title>
<style>
body {
margin: 0; /* Remove default margin */
}
</style>
</head>
<body>
</body>
<script type="text/javascript" src="/ajax.js"></script>
<script type="text/javascript">
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
document.addEventListener('DOMContentLoaded', function(){
ajax('post', 'https://github.com/login/oauth/access_token', {
client_id: '7480d3802f0259608aec',
client_secret: '57a53a7ceb0d07807b3ef47c29a6b9954408422c',
code: getParameterByName('code')
},
function(data){
debugger
},
function(err){
debugger
})
})
</script>
</html>