Skip to content

Commit c845f1f

Browse files
committed
attempted G+ signin integration
1 parent 9604140 commit c845f1f

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

‎v3/composingprograms.html‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@
7474

7575

7676
<table id="experimentalHeader" style="margin-bottom: 15pt;">
77+
78+
79+
<span id="signinButton">
80+
<span
81+
class="g-signin"
82+
data-callback="signinCallback"
83+
data-clientid="639826413051-n4c566bfu9jnee6893qolvbt8od9kiaf.apps.googleusercontent.com"
84+
data-cookiepolicy="single_host_origin"
85+
data-requestvisibleactions="http://schemas.google.com/AddActivity"
86+
data-scope="https://www.googleapis.com/auth/plus.profile.emails.read">
87+
</span>
88+
</span>
89+
90+
7791
<tr>
7892
<td valign="top">
7993
<div style="font-size: 8pt; color: #666; margin-left: 2px;">Experimental features</div>
@@ -183,6 +197,16 @@
183197

184198
</div>
185199

200+
201+
<!-- Place this asynchronous JavaScript just before your </body> tag -->
202+
<script type="text/javascript">
203+
(function() {
204+
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
205+
po.src = 'https://apis.google.com/js/client:plusone.js';
206+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
207+
})();
208+
</script>
209+
186210
</body>
187211
</html>
188212

‎v3/js/composingprograms.js‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,31 @@ $(document).ready(function() {
8383

8484
genericOptFrontendReady(); // initialize at the very end
8585
});
86+
87+
88+
// for Google+ Web signin:
89+
// https://developers.google.com/+/web/signin/add-button
90+
91+
function signinCallback(authResult) {
92+
if (authResult) {
93+
if (authResult['error'] == undefined){
94+
95+
// This sample assumes a client object has been created.
96+
// To learn more about creating a client, check out the starter:
97+
// https://developers.google.com/+/quickstart/javascript
98+
gapi.client.load('plus','v1', function(){
99+
var request = gapi.client.plus.people.get({
100+
'userId': 'me'
101+
});
102+
request.execute(function(resp) {
103+
alert('Retrieved profile for "' + resp.displayName + '"');
104+
});
105+
});
106+
107+
} else {
108+
console.log('An error occurred');
109+
}
110+
} else {
111+
console.log('Empty authResult'); // Something went wrong
112+
}
113+
}

0 commit comments

Comments
 (0)