Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0 hybridity #159

Merged
merged 2 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
bower_components
bower_components*
bower-*.json
35 changes: 26 additions & 9 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "google-signin",
"version": "1.3.7",
"version": "2.0.0",
"description": "Web components to authenticate with Google services",
"homepage": "https://googlewebcomponents.github.io/google-signin",
"main": "google-signin.html",
Expand All @@ -22,16 +22,33 @@
"authentication"
],
"dependencies": {
"polymer": "Polymer/polymer#^1.0.0",
"polymer": "Polymer/polymer#1.9 - 2",
"font-roboto": "PolymerElements/font-roboto#^1.0.0",
"iron-icon": "PolymerElements/iron-icon#^1.0.0",
"iron-iconset-svg": "PolymerElements/iron-iconset-svg#^1.0.0",
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.3.0",
"paper-ripple": "PolymerElements/paper-ripple#^1.0.0",
"paper-material": "PolymerElements/paper-material#^1.0.0",
"google-apis": "GoogleWebComponents/google-apis#^1.0.0"
"iron-icon": "PolymerElements/iron-icon#1 - 2",
"iron-iconset-svg": "PolymerElements/iron-iconset-svg#1 - 2",
"iron-flex-layout": "PolymerElements/iron-flex-layout#1 - 2",
"paper-ripple": "PolymerElements/paper-ripple#1 - 2",
"paper-material": "PolymerElements/paper-material#1 - 2",
"google-apis": "GoogleWebComponents/google-apis#1 - 2"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.2"
"iron-component-page": "PolymerElements/iron-component-page#1 - 2"
},
"variants": {
"1.x": {
"dependencies": {
"polymer": "Polymer/polymer#^1.0.0",
"font-roboto": "PolymerElements/font-roboto#^1.0.0",
"iron-icon": "PolymerElements/iron-icon#^1.0.0",
"iron-iconset-svg": "PolymerElements/iron-iconset-svg#^1.0.0",
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.3.0",
"paper-ripple": "PolymerElements/paper-ripple#^1.0.0",
"paper-material": "PolymerElements/paper-material#^1.0.0",
"google-apis": "GoogleWebComponents/google-apis#^1.0.0"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0"
}
}
}
}
106 changes: 56 additions & 50 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,61 +84,68 @@
<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>&lt;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>openid-prompt=
<input type="checkbox" checked="{{openidPrompt.none::change}}">none
<input type="checkbox" checked="{{openidPrompt.login::change}}">login
<input type="checkbox" checked="{{openidPrompt.consent::change}}">consent
<input type="checkbox"
checked="{{openidPrompt.select_account::change}}">select_account
</div>
<div>offline=<input type="checkbox" checked="{{offline::change}}"></div>
<div>initialized="<span>{{initialized}}</span>"</div>
<div>signedIn="<span>{{signedIn}}</span>"</div>
<div>isAuthorized="<span>{{isAuthorized}}</span>"</div>
<div>needAdditionalAuth:"<span>{{needAdditionalAuth}}</span>"&gt;</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}}"
openid-prompt="{{openidPromptValue}}"
initialized="{{initialized}}"
signed-in="{{signedIn}}"
offline="{{offline}}"
is-authorized="{{isAuthorized}}"
need-additional-auth="{{needAdditionalAuth}}"
on-google-signin-aware-error="handleSignInError"
on-google-signin-aware-success="handleSignIn"
on-google-signin-offline-success="handleOffline"
on-google-signin-aware-signed-out="handleSignOut"
on-signed-in-changed="handleStateChange"
on-initialized-changed="handleStateChange"></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>Only display "not signed in" element after auth state is initialized (avoid flickering): <b hidden id="not-signed-in">Not signed in!</b></p>
<p><button on-click="disconnect">Disconnect to start over</button></p>
</template>
<dom-bind id="awareness">
<template is="dom-bind">
<div><code>&lt;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>openid-prompt=
<input type="checkbox" checked="{{openidPrompt.none::change}}">none
<input type="checkbox" checked="{{openidPrompt.login::change}}">login
<input type="checkbox" checked="{{openidPrompt.consent::change}}">consent
<input type="checkbox"
checked="{{openidPrompt.select_account::change}}">select_account
</div>
<div>offline=<input type="checkbox" checked="{{offline::change}}"></div>
<div>initialized="<span>{{initialized}}</span>"</div>
<div>signedIn="<span>{{signedIn}}</span>"</div>
<div>isAuthorized="<span>{{isAuthorized}}</span>"</div>
<div>needAdditionalAuth:"<span>{{needAdditionalAuth}}</span>"&gt;</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}}"
openid-prompt="{{openidPromptValue}}"
initialized="{{initialized}}"
signed-in="{{signedIn}}"
offline="{{offline}}"
is-authorized="{{isAuthorized}}"
need-additional-auth="{{needAdditionalAuth}}"
on-google-signin-aware-error="handleSignInError"
on-google-signin-aware-success="handleSignIn"
on-google-signin-offline-success="handleOffline"
on-google-signin-aware-signed-out="handleSignOut"
on-signed-in-changed="handleStateChange"
on-initialized-changed="handleStateChange"></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>Only display "not signed in" element after auth state is initialized (avoid flickering): <b hidden id="not-signed-in">Not signed in!</b></p>
<p><button on-click="disconnect">Disconnect to start over</button></p>
</template>
</dom-bind>
<script>
var aware = document.querySelector('#awareness');
if (!Polymer.Element) {
aware = aware.querySelector('template');
}

aware.status = 'Not granted';
aware.offlineCode = 'No offline login.';
aware.userName = 'N/A';
aware.openidPrompt = {};

aware.handleSignInError = function(event) {
this.status = JSON.stringify(event.detail);
};
Expand All @@ -156,7 +163,6 @@
this.userName = 'N/A';
};
aware.disconnect = function() {
var b = document.querySelector('google-signin');
var currentUser = gapi.auth2.getAuthInstance().currentUser.get();
if (currentUser) {
currentUser.disconnect();
Expand Down
3 changes: 3 additions & 0 deletions google-signin-aware.html
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@
init: function() {
this._apiLoader = document.createElement('google-js-api');
this._apiLoader.addEventListener('js-api-load', this.loadAuth2.bind(this));
if (Polymer.Element) {
document.body.appendChild(this._apiLoader);
}
},

loadAuth2: function() {
Expand Down