-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogleauth.php
More file actions
76 lines (73 loc) · 2.66 KB
/
googleauth.php
File metadata and controls
76 lines (73 loc) · 2.66 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Application</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.google-auth-button {
display: inline-block;
background-color: #db4a39;
color: white;
border: none;
border-radius: 5px;
padding: 10px 20px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s, transform 0.2s;
}
.google-auth-button:hover {
background-color: #c53726;
transform: scale(1.05);
}
.google-auth-icon {
margin-right: 10px;
}
.google-auth-text {
vertical-align: middle;
}
</style>
</head>
<body>
<div class="google-auth-button" id="googleSignInButton">
<span class="google-auth-icon"><i class="fab fa-google"></i></span>
<span class="google-auth-text">Sign in with Google</span>
</div>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const googleSignInButton = document.getElementById('googleSignInButton');
googleSignInButton.addEventListener('click', () => {
gapi.load('auth2', function() {
gapi.auth2.init({
client_id: '1084905472943-u9m52a3h1vjl0ui4coah403hsjtmjb0c.apps.googleusercontent.com',
}).then(() => {
const auth2 = gapi.auth2.getAuthInstance();
auth2.signIn().then(onSignIn);
});
});
});
});
function onSignIn(googleUser) {
const profile = googleUser.getBasicProfile();
console.log('ID: ' + profile.getId());
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail());
// You can use the profile information to customize your application's behavior.
// For example, you can display the user's name and profile picture.
}
</script>
</body>
</html>