Update user.html
Browse files
user.html
CHANGED
@@ -6,11 +6,12 @@
|
|
6 |
<title>VK Authorization</title>
|
7 |
</head>
|
8 |
<body>
|
9 |
-
|
10 |
<script src="https://unpkg.com/@vkid/sdk@<3.0.0/dist-sdk/umd/index.js"></script>
|
11 |
<script type="text/javascript">
|
12 |
if ("VKIDSDK" in window) {
|
13 |
const VKID = window.VKIDSDK;
|
|
|
14 |
VKID.Config.init({
|
15 |
"app": 52295022,
|
16 |
"redirectUrl": "https://dmtuit-psy-vk.hf.space/pages",
|
@@ -18,8 +19,9 @@
|
|
18 |
});
|
19 |
|
20 |
const oneTap = new VKID.OneTap();
|
|
|
21 |
oneTap.render({
|
22 |
-
"container": document.
|
23 |
"showAlternativeLogin": true,
|
24 |
"styles": {
|
25 |
"width": 360
|
@@ -34,31 +36,21 @@
|
|
34 |
const code = payload.code;
|
35 |
const deviceId = payload.device_id;
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
headers: {
|
41 |
-
'Content-Type': 'application/json'
|
42 |
-
},
|
43 |
-
body: JSON.stringify({ code, deviceId })
|
44 |
-
})
|
45 |
-
.then(response => response.json())
|
46 |
-
.then(data => {
|
47 |
-
if (data.error) {
|
48 |
-
console.error('Error from server:', data.error);
|
49 |
-
} else {
|
50 |
-
console.log('User Info:', data);
|
51 |
-
// Здесь можно обработать полученные данные о пользователе
|
52 |
-
}
|
53 |
-
})
|
54 |
-
.catch(vkidOnError);
|
55 |
});
|
56 |
}
|
57 |
-
|
|
|
|
|
|
|
|
|
58 |
function vkidOnError(error) {
|
59 |
-
|
60 |
}
|
61 |
</script>
|
|
|
62 |
|
63 |
</body>
|
64 |
</html>
|
|
|
6 |
<title>VK Authorization</title>
|
7 |
</head>
|
8 |
<body>
|
9 |
+
<div>
|
10 |
<script src="https://unpkg.com/@vkid/sdk@<3.0.0/dist-sdk/umd/index.js"></script>
|
11 |
<script type="text/javascript">
|
12 |
if ("VKIDSDK" in window) {
|
13 |
const VKID = window.VKIDSDK;
|
14 |
+
|
15 |
VKID.Config.init({
|
16 |
"app": 52295022,
|
17 |
"redirectUrl": "https://dmtuit-psy-vk.hf.space/pages",
|
|
|
19 |
});
|
20 |
|
21 |
const oneTap = new VKID.OneTap();
|
22 |
+
|
23 |
oneTap.render({
|
24 |
+
"container": document.currentScript.parentElement,
|
25 |
"showAlternativeLogin": true,
|
26 |
"styles": {
|
27 |
"width": 360
|
|
|
36 |
const code = payload.code;
|
37 |
const deviceId = payload.device_id;
|
38 |
|
39 |
+
VKID.Auth.exchangeCode(code, deviceId)
|
40 |
+
.then(vkidOnSuccess)
|
41 |
+
.catch(vkidOnError);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
});
|
43 |
}
|
44 |
+
|
45 |
+
function vkidOnSuccess(data) {
|
46 |
+
// Обработка полученного результата
|
47 |
+
}
|
48 |
+
|
49 |
function vkidOnError(error) {
|
50 |
+
// Обработка ошибки
|
51 |
}
|
52 |
</script>
|
53 |
+
</div>
|
54 |
|
55 |
</body>
|
56 |
</html>
|