Repository navigation
Expand file tree
/
Copy pathmain.html
More file actions
103 lines (83 loc) · 3.11 KB
/
Copy pathmain.html
File metadata and controls
103 lines (83 loc) · 3.11 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>메인화면</title>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/nav.css">
</head>
<body>
<div class="main-text container">
<div>이평야 님의 일기장</div>
</div>
<div class="scroll container">
<div class="my-diary container">
<div class="text">my_today
<img src="./images/icons/edit.png">
</div>
<div class="diary-cover container">
</div>
</div>
</div>
<div class="nav conainter">
<ul class="nav-list">
<li class="nav-item"><a href="home.html" class="nav-link"><img src="images/icons/nav_home.png"></a></li>
<li class="nav-item"><a href="search.html" class="nav-link"><img src="images/icons/nav_search.png"></a></li>
<li class="nav-item"><a href="mypage.html" class="nav-link"><img src="images/icons/nav_person.png"></a></li>
</ul>
</div>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script>
const REST_API_KEY = "90948feb4d923809c73dd667a2ba1e33";
const kakaoTokenApiUrl = "https://kauth.kakao.com/oauth/token";
const kakaoUserApiUrl = "https://kapi.kakao.com/v2/user/me";
const redirectUrl = "http://127.0.0.1:5501/main.html";
const urlParams = new URL(location.href).searchParams;
const code = urlParams.get('code');
const user = getKakaoUserInfo(getKakaoToken(code));
function getKakaoToken(code) {
let token = "";
let data = {
"grant_type": "authorization_code",
"client_id": REST_API_KEY,
"redirect_uri": redirectUrl,
"code": code,
};
$.ajax(kakaoTokenApiUrl, {
data: data,
dataType: "json",
method: "POST",
async: false,
success: function (resultData) {
token = resultData.access_token;
console.log(token);
}
});
return token;
}
function getKakaoUserInfo(token) {
let user = "";
$.ajax(kakaoUserApiUrl, {
data: {
"secure_resoruce" : true
},
headers: {
'Authorization': `Bearer ${token}`,
'Content-type': `application/x-www-form-urlencoded;charset=utf-8`,
},
dataType: "json",
method: "GET",
async: false,
success: function (resultData) {
console.log(resultData);
user = resultData;
}
});
return user;
}
</script>
<meta http-equiv="refresh" content='0.01;url=diaryCoverList.html'>
</body>
</html>