index.html
5.3 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!doctype html>
<!-- Copyright (c) 2014 Google Inc. All rights reserved. -->
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>google-signin Demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../google-signin.html">
<link rel="import" href="../google-signin-aware.html">
<!-- Demo only styles -->
<style>
body {
font-family: 'RobotoDraft', 'Roboto', sans-serif;
line-height:1.2;
vertical-align:middle;
background: rgba(204, 204, 204, 0.31);
}
.map {
background: whitesmoke;
margin: .5rem -1.5rem 0 -1.5rem;
padding: 0.5rem;
}
h1 {
font-size: 2rem;
font-weight:200;
clear: both;
}
h1 strong {
font-weight:300;
color:#539D00;
}
h2 {
font-size:.9rem;
line-height:2.5;
color:gray;
font-weight:400;
clear: both;
}
.showcase {
display: inline-block;
margin-right: 2rem;
float: left;
}
</style>
</head>
<body>
<p>A <code><google-signin></code> element looks like this button:</p>
<p><google-signin brand="google" client-id="1054047045356-j8pgqgls9vdef3rl09hapoicumbte0bo.apps.googleusercontent.com"></google-signin>
or like this if plus scopes are present
<google-signin brand="google-plus"></google-signin>
</p>
<p>Signin button can vary its appearance:</p>
<p>Width:
<google-signin brand="google" width="wide"></google-signin>
<google-signin brand="google" width="iconOnly"></google-signin>
Height:
<google-signin brand="google" height="tall"></google-signin>
<google-signin brand="google" height="standard"></google-signin>
<google-signin brand="google" height="short"></google-signin>
</p>
<p>
Theme:
<google-signin brand="google" theme="dark"></google-signin>
<google-signin brand="google" theme="light"></google-signin>
<google-signin brand="google-plus" theme="light"></google-signin>
<google-signin brand="google-plus" theme="light" raised></google-signin>
</p>
<!-- Demo the ability to use the google-signin-aware element. -->
<p><code><google-signin-aware></code> is a companion element.</p>
<p>You can use it inside your components to request additional scopes.</p>
<p>Every signin button will request all the scopes present in the document,
and change its appearance to match</p>
<p>For example, here is a signin-aware scope. You can change its scopes via popup</p>
<template id="awareness" is="dom-bind">
<div><code><google-signin-aware
<div>scope=
<select value="{{scope::change}}">
<option value="">None</option>
<option value="https://www.googleapis.com/auth/analytics">Google Analytics</option>
<option value="https://www.googleapis.com/auth/plus.login">Google Plus view circles</option>
<option value="https://www.googleapis.com/auth/youtube">YouTube</option>
<option value="https://www.googleapis.com/auth/calendar">Calendar</option>
<option value="profile">Profile info</option>
</select>
</div>
<div>offline=<input type="checkbox" checked="{{offline::change}}"></div>
<div>signedIn="<span>{{signedIn}}</span>"</div>
<div>isAuthorized="<span>{{isAuthorized}}</span>"</div>
<div>needAdditionalAuth:"<span>{{needAdditionalAuth}}</span>"></div>
</code></div>
<p>Every new scope you select will be added to requested scopes.</p>
<p>When you select a Google Plus scope, button will turn red.</p>
<google-signin></google-signin>
</p>
<google-signin-aware
scopes="{{scope}}"
signed-in="{{signedIn}}"
offline="{{offline}}"
is-authorized="{{isAuthorized}}"
need-additional-auth="{{needAdditionalAuth}}"
on-google-signin-aware-success="handleSignIn"
on-google-signin-offline-success="handleOffline"
on-google-signin-aware-signed-out="handleSignOut"></google-signin-aware>
<p>User name:<span>{{userName}}</span></p>
<p>Testing <code>google-signin-aware</code> events: <span>{{status}}</span></p>
<p>Testing <code>google-signin-offline</code> events: <span>{{offlineCode}}</span></p>
<p><button on-click="disconnect">Disconnect to start over</button></p>
</template>
<script>
var aware = document.querySelector('#awareness');
aware.status = 'Not granted';
aware.offlineCode = 'No offline login.';
aware.userName = 'N/A';
aware.handleSignIn = function(response) {
this.status = 'Signin granted';
// console.log('[Aware] Signin Response', response);
this.userName = gapi.auth2.getAuthInstance().currentUser.get().getBasicProfile().getName();
};
aware.handleOffline = function(response) {
this.offlineCode = response.detail.code;
};
aware.handleSignOut = function(response) {
this.status = 'Signed out';
// console.log('[Aware] Signout Response', response);
this.userName = 'N/A';
};
aware.disconnect = function() {
var b = document.querySelector('google-signin');
var currentUser = gapi.auth2.getAuthInstance().currentUser.get();
if (currentUser) {
currentUser.disconnect();
}
gapi.auth2.getAuthInstance().signOut();
};
</script>
</body>
</html>