1<div class='g-sign-in-button'>
2 <div class=content-wrapper>
3 <div class='logo-wrapper'>
4 <img src='https://developers.google.com/identity/images/g-logo.png'>
5 </div>
6 <span class='text-container'>
7 <span>Sign in with Google</span>
8 </span>
9 </div>
10</div>
11
12<style>
13 *, *:before, *:after {
14 box-sizing: border-box;
15 }
16
17 .g-sign-in-button {
18 margin: 10px;
19 display: inline-block;
20 width: 240px;
21 height: 50px;
22 background-color: #4285f4;
23 color: #fff;
24 border-radius: 1px;
25 box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.25);
26 transition: background-color .218s, border-color .218s, box-shadow .218s;
27 }
28
29 .g-sign-in-button:hover {
30 cursor: pointer;
31 -webkit-box-shadow: 0 0 3px 3px rgba(66, 133, 244, 0.3);
32 box-shadow: 0 0 3px 3px rgba(66, 133, 244, 0.3);
33 }
34
35 .g-sign-in-button:active {
36 background-color: #3367D6;
37 transition: background-color 0.2s;
38 }
39
40 .g-sign-in-button .content-wrapper {
41 height: 100%;
42 width: 100%;
43 border: 1px solid transparent;
44 }
45
46 .g-sign-in-button img {
47 width: 18px;
48 height: 18px;
49 }
50
51 .g-sign-in-button .logo-wrapper {
52 padding: 15px;
53 background: #fff;
54 width: 48px;
55 height: 100%;
56 border-radius: 1px;
57 display: inline-block;
58 }
59
60 .g-sign-in-button .text-container {
61 font-family: Roboto,arial,sans-serif;
62 font-weight: 500;
63 letter-spacing: .21px;
64 font-size: 16px;
65 line-height: 48px;
66 vertical-align: top;
67 border: none;
68 display: inline-block;
69 text-align: center;
70 width: 180px;
71 }
72
73</style>
1<html><head> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css"> <script src="https://apis.google.com/js/api:client.js"></script> <script> var googleUser = {}; var startApp = function() { gapi.load('auth2', function(){ // Retrieve the singleton for the GoogleAuth library and set up the client. auth2 = gapi.auth2.init({ client_id: 'YOUR_CLIENT_ID.apps.googleusercontent.com', cookiepolicy: 'single_host_origin', // Request scopes in addition to 'profile' and 'email' //scope: 'additional_scope' }); attachSignin(document.getElementById('customBtn')); }); }; function attachSignin(element) { console.log(element.id); auth2.attachClickHandler(element, {}, function(googleUser) { document.getElementById('name').innerText = "Signed in: " + googleUser.getBasicProfile().getName(); }, function(error) { alert(JSON.stringify(error, undefined, 2)); }); } </script> <style type="text/css"> #customBtn { display: inline-block; background: white; color: #444; width: 190px; border-radius: 5px; border: thin solid #888; box-shadow: 1px 1px 1px grey; white-space: nowrap; } #customBtn:hover { cursor: pointer; } span.label { font-family: serif; font-weight: normal; } span.icon { background: url('/identity/sign-in/g-normal.png') transparent 5px 50% no-repeat; display: inline-block; vertical-align: middle; width: 42px; height: 42px; } span.buttonText { display: inline-block; vertical-align: middle; padding-left: 42px; padding-right: 42px; font-size: 14px; font-weight: bold; /* Use the Roboto font that is loaded in the <head> */ font-family: 'Roboto', sans-serif; } </style> </head> <body> <!-- In the callback, you would hide the gSignInWrapper element on a successful sign in --> <div id="gSignInWrapper"> <span class="label">Sign in with:</span> <div id="customBtn" class="customGPlusSignIn"> <span class="icon"></span> <span class="buttonText">Google</span> </div> </div> <div id="name"></div> <script>startApp();</script></body></html>