-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.html
844 lines (784 loc) · 27.7 KB
/
template.html
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
<!--
Google IO 2013: Cross-Platform Auth with Google+ Sign-In
Authors: Chris Cartland <[email protected]>
Francis Ma <[email protected]>
Based on template by:
Eric Bidelman <[email protected]>
Luke Mahé <[email protected]>
URL: https://code.google.com/p/io-2012-slides
-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<!--<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">-->
<!--<meta name="viewport" content="width=device-width, initial-scale=1.0">-->
<!--This one seems to work all the time, but really small on ipad-->
<!--<meta name="viewport" content="initial-scale=0.4">-->
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" media="all" href="theme/css/default.css">
<link rel="stylesheet" media="all" href="theme/css/io2013.css">
<link rel="stylesheet" media="all" href="theme/css/cartland.css">
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="theme/css/phone.css">
<base target="_blank"> <!-- This amazingness opens all links in a new tab. -->
<script data-main="js/slides" src="js/require-1.0.8.min.js"></script>
</head>
<body style="opacity: 0">
<slides class="layout-widescreen">
<slide class="logoslide nobackground">
<article class="flexbox vcenter">
<span><img src="images/google_developers_logo.png"></span>
</article>
</slide>
<slide class="title-slide segue nobackground">
<aside class="gdbar"><img src="images/google_developers_icon_128.png"></aside>
<!-- The content of this hgroup is replaced programmatically through the slide_config.json. -->
<hgroup class="auto-fadein">
<h1 data-config-title><!-- populated from slide_config.json --></h1>
<h2 data-config-subtitle><!-- populated from slide_config.json --></h2>
<p data-config-presenter><!-- populated from slide_config.json --></p>
</hgroup>
</slide>
<slide>
<hgroup>
<h2>Agenda</h2>
</hgroup>
<article class="flexbox vcenter" class="larger">
<ul>
<li>"Auth" and Google+ Sign-In</li>
<li>Auth Triangle: Your Client, Server, and Google</li>
<li>Client auth models across Android, iOS, and Web</li>
<li>Server auth</li>
<li>Choosing the right one for you</li>
<li>Q&A: Submit and vote on questions here <a href="http://goo.gl/48LOh">http://goo.gl/48LOh</a></li>
</ul>
</article>
</slide>
<slide>
<hgroup>
<h2>Talking about "auth"</h2>
</hgroup>
<article class="flexbox vcenter" style="float: left; width: 50%">
<ul>
<li>Authentication</li>
<ul>
<li>Verifies who you are</li>
</ul>
<li>Authorization</li>
<ul>
<li>Permission to do something</li>
</ul>
</ul>
</article>
<article class="flexbox vcenter" style="float:right; width:50%; margin-top: -30px;">
<img width="250px" src="images/identification.png" alt="California Identification" title="California Identification"><br />
<img style="margin-left: 30px;" width="200px" src="images/io-badge.jpg" class="reflect" alt="Google I/O Badge" title="Google I/O Badge"><br />
</article>
</slide>
<slide>
<hgroup>
<h2>Don't Build Your Own Authentication!</h2>
</hgroup>
<article class="flexbox vcenter" style="float: left; width: 50%">
<ul>
<li>Lots to worry about</li>
<ul>
<li>Encrypt traffic</li>
<li>Hash + salt password</li>
<li>2-factor authentication</li>
<li>Account recovery</li>
<li>More...</li>
</ul>
</ul>
</article>
<article style="float:right; width:35%; margin-top:30px;">
<img width="100%" src="images/rocket-science.jpg" class="reflect" alt="Rocket Science" title="Rocket Science"><br />
<footer class="source">
http://spaceflight.nasa.gov/gallery/images/shuttle/sts-121/hires/sts121-s-030.jpg
</footer>
</article>
</slide>
<slide>
<hgroup>
<h2>Making Headline News</h2>
<h3>... but not the way you want.</h3>
</hgroup>
<article class="flexbox vcenter" style="margin-top:-30px;">
<img src="images/hack-headlines.png" class="reflect" alt="Hack Headlines" title="Hack Headlines">
<footer class="source">
Google News, May 11, 2013
</footer>
</article>
</slide>
<slide>
<hgroup>
<h2>Use An Identity Provider</h2>
</hgroup>
<article class="flexbox vcenter" style="float: left; width:50%">
<ul>
<li>Easier for you and the user</li>
<li>Can ask for authorization for additional features</li>
<li>A better way to reach your goal</li>
</ul>
</article>
<article style="float:right; width:50%; margin-top:30px;">
<img width="100%" src="images/safe-travels.jpg" class="reflect" alt="Reach Your Goal" title="Reach Your Goal"><br />
<footer class="source">
http://www.nasa.gov/centers/dryden/images/content/690557main_SCA_Endeavour_over_Ventura.jpg
</footer>
</article>
</slide>
<slide>
<hgroup>
<h2></h2>
</hgroup>
<article class="flexbox vcenter">
<img width="600px" src="images/sign-in-button.png" class="reflect" alt="Google+ Sign-In" title="Google+ Sign-In">
<footer class="source">Google+ Sign-In Button</footer>
</article>
</slide>
<slide class="segue dark nobackground">
<aside class="gdbar"><img src="images/google_developers_icon_128.png"></aside>
<hgroup class="auto-fadein">
<h2>How Does Google+ Sign-In Work?</h2>
</hgroup>
</slide>
<slide>
<hgroup>
<h2>Based on OAuth 2.0</h2>
</hgroup>
<article class="flexbox vcenter">
<img style="position: absolute; right: 40px; top:30px;" src="images/oauth-2-sm.png" class="reflect" alt="OAuth 2.0" title="OAuth 2.0">
<img width="800px" src="images/permission.png" class="reflect" alt="Permission Triangle" title="Permission Triangle">
<footer class="source">OAuth 2.0 logo from http://oauth.net/2/</footer>
</article>
</slide>
<slide>
<hgroup>
<h2>Google API Console Project</h2>
<h3>https://developers.google.com/console</h3>
</hgroup>
<article style="float: left; width: 60%">
<ul>
<li>Create one project for your app with</li>
<ul>
<li>Branding information</li>
<li>Multiple clients</li>
</ul>
</ul>
<table>
<tr>
<th>Platform</th><th>Client Info</th>
</tr>
<tr>
<td>Android</td><td>App Package Name</td>
</tr>
<tr>
<td>iOS</td><td>Bundle ID</td>
</tr>
<tr>
<td>Web</td><td>JavaScript Origins</td>
</tr>
</table>
</article>
<article style="float:right; width:40%; margin-top:-100px;" class="flexbox vcenter">
<img width="350px" src="images/create-api-console-project.png" class="reflect" alt="Create Google API Console Project" title="Create Google API Console Project"><br />
</article>
</slide>
<slide>
<hgroup>
<h2>Structuring your API Project correctly is important!</h2>
</hgroup>
<article class="flexbox vcenter">
<ul>
<li>Authorization is granted to your app, not a specific client</li>
<li>For Android & Web:</li>
<ul>
<li>Single user consent across clients</li>
<li>Google+ Sign-In automatically initializes clients with auth tokens, if available</li>
<li>Cross-platform Single Sign On</li>
</ul>
</ul>
</article>
</slide>
<slide class="segue dark nobackground">
<aside class="gdbar"><img src="images/google_developers_icon_128.png"></aside>
<hgroup class="auto-fadein">
<h2>Your Client, Server, and Google</h2>
</hgroup>
</slide>
<slide>
<hgroup>
<h2>Auth Triangle: Your Client, Server, and Google</h2>
<h3>The connecting lines require auth</h3>
</hgroup>
<article class="flexbox vcenter" style="margin-top:-30px;">
<img width="600px" src="images/auth-triangle.png" class="reflect" alt="Auth Triangle" title="Auth Triangle">
</article>
</slide>
<slide class="segue dark nobackground">
<aside class="gdbar"><img src="images/google_developers_icon_128.png"></aside>
<hgroup class="auto-fadein">
<h2>Client Auth: How to connect your app client with Google</h2>
</hgroup>
</slide>
<slide>
<hgroup>
<h2>Client Auth</h2>
</hgroup>
<article class="larger" style="float: left; width: 35%">
<ul>
<li>Android</li>
<li>iOS</li>
<li>Web</li>
</ul>
</article>
<article style="float:right; width:60%; margin-top: 75px;">
<img width="100%" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth"><br />
</article>
</slide>
<slide>
<hgroup>
<h2>Android: Client Auth</h2>
</hgroup>
<article class="flexbox vcenter" style="float: left; width: 50%">
<ul>
<li>Managed via Google Play services API</li>
<ul>
<li>Available on Android 2.2+</li>
</ul>
<li>Auth using Google accounts on the device</li>
</ul>
</article>
<article style="float:right; width:40%; margin-top:30px;">
<img width="100%" src="images/android-client.png" class="reflect" alt="Android Client Auth" title="Android Client Auth"><br />
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>Android: Client Auth</h2>
<h3>Connection Lifecycle</h3>
</hgroup>
<article class="flexbox vcenter">
<img style="height:80%; margin-top:-35%;" src="images/PlusClient-Lifecycle.png" class="reflect" alt="Resolution Lifecycle" title="Resolution Lifecycle">
<footer class="source">http://www.riskcompletefailure.com/2013/03/common-problems-with-google-sign-in-on.html</footer>
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>Android: Client Auth</h2>
<h3>Coincides with the Android Activity Lifecycle</h3>
</hgroup>
<article style="float: left; width: 150px">
<img width="100%" src="images/android-connection-lifecycle.png" class="reflect" alt="Android Connection Lifecycle" title="Android Connection Lifecycle"><br />
</article>
<article style="float:right; width:70%">
<pre class="prettyprint" data-lang="android">
<b>mPlusClient = new PlusClient.Builder(this, this, this)
.setScopes(SCOPES).build();
findViewById(R.id.sign_in_button)
.setOnClickListener(this);</b>
</pre>
<pre class="prettyprint" data-lang="android">
<b>mPlusClient.connect();</b>
</pre>
<pre class="prettyprint" data-lang="xml">
<b><com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /></b>
</pre>
<pre class="prettyprint" data-lang="android">
<b>mPlusClient.disconnect();</b>
</pre>
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>Android: Client Auth</h2>
<h3>Handle callback from mPlusClient.connect()</h3>
</hgroup>
<article>
<pre class="prettyprint" data-lang="android">
<b>public void onConnectionFailed(ConnectionResult result) {
// Save the result and resolve the connection failure upon a user click.
mConnectionResult = result;
}
public void onConnected() {
Person current = mPlusClient.getCurrentPerson();
String gplusId = current.getId();
}</b>
</pre>
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>Android: Client Auth</h2>
<h3>Start Google Play services resolution onClick</h3>
</hgroup>
<article>
<pre class="prettyprint" data-lang="android">
public void onClick(View view) {
<b>if (view.getId() == R.id.sign_in_button // Sign-In Button
&& !mPlusClient.isConnected() // Not signed in
&& mConnectionResult != null) { // We have next steps</b>
try {
<b>mConnectionResult.startResolutionForResult(this,
REQUEST_CODE_RESOLVE_ERR);</b>
} catch (SendIntentException e) {
mConnectionResult = null;
mPlusClient.connect();
}
}
}
</pre>
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>Android: Client Auth</h2>
<h3>Call connect() when Google Play services is done</h3>
</hgroup>
<article>
<pre class="prettyprint" data-lang="android">
protected void <b>onActivityResult</b>(int requestCode,
int responseCode, Intent intent) {
if (requestCode == REQUEST_CODE_RESOLVE_ERR
&& responseCode == RESULT_OK) {
mConnectionResult = null;
<b>mPlusClient.connect();</b>
}
}
</pre>
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>Android: Client Auth</h2>
<h3>Connection Lifecycle</h3>
</hgroup>
<article class="flexbox vcenter">
<img style="height:80%; margin-top:-35%;" src="images/PlusClient-Lifecycle.png" class="reflect" alt="Resolution Lifecycle" title="Resolution Lifecycle">
<footer class="source">http://www.riskcompletefailure.com/2013/03/common-problems-with-google-sign-in-on.html</footer>
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>iOS: Client Auth</h2>
</hgroup>
<article class="flexbox vcenter" style="float: left; width: 50%">
<ul>
<li>Integrate with Google+ iOS SDK</li>
<li>SDK handles auth flows and token management</li>
</ul>
</article>
<article style="float:right; width:40%; margin-top:30px;">
<img width="100%" src="images/ios-client.png" class="reflect" alt="iOS Client Auth" title="iOS Client Auth">
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>iOS: Client Auth</h2>
<h3>Setup Sign-In</h3>
</hgroup>
<article>
<pre class="prettyprint" data-lang="objective-c">
// In .m files as needed, or in your .pch file.
<b>#import <GooglePlus/GooglePlus.h>
#import <GoogleOpenSource/GoogleOpenSource.h>
// In AppDelegate.m
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.clientID = @"YOUR_CLIENT_ID"
signIn.scopes = kScopes;
signIn.shouldFetchGoogleUserID = YES;
signIn.delegate = self; // Implements GPPSignInDelegate protocol
}</b>
</pre>
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>iOS: Client Auth</h2>
<h3>User initiates with Sign-In Button</h3>
</hgroup>
<article>
<ul>
<li>Add a button to your view</li>
<!-- <li>Remove the default label</li> -->
<li>Set custom class to GPPSignIn</li>
<li>SDK localizes button and manages authflow</li>
<p>
<p>
OR
<li>Create your own button following our branding guidelines</li>
<li>Then explicitly call the following in the IBAction</li>
<pre class="prettyprint" data-lang="objective-c">
<b>[[GPPSignIn sharedInstance] authenticate];</b>
</pre>
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>iOS: Client Auth</h2>
<!--<h3>Receive Sign-In Information</h3>-->
</hgroup>
<article>
<pre class="prettyprint" data-lang="objective-c">
// In AppDelegate.m
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return <b>[GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation];</b>
}
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
if (!error) {
<b>NSString *gplusId = [GPPSignIn sharedInstance].userID;</b>
}
}
</pre>
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>Web: Client Auth</h2>
</hgroup>
<article class="flexbox vcenter" style="float: left; width: 50%">
<ul>
<li>Simply include the JavaScript client</li>
<li>Add Google+ Sign-In Button</li>
<li>Handle auth callback</li>
</ul>
</article>
<article style="float:right; width:50%; margin-top: 150px;">
<img width="100%" src="images/web-client.png" alt="Web Client Auth" title="Web Client Auth">
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>Web: Client Auth</h2>
<h3>Add Sign-In Button element and include JavaScript</h3>
</hgroup>
<article>
<pre class="prettyprint" data-lang="HTML">
<b><span id="signinButton">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="CLIENT_ID"
data-cookiepolicy="single_host_origin"
data-scope="https://www.googleapis.com/auth/plus.login">
</span>
</span>
<!-- Place plusone.js asynchronous JavaScript
just before your </body> tag --></b>
</pre>
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide>
<hgroup>
<h2>Web: Client Auth</h2>
<h3>Handle auth callback</h3>
</hgroup>
<article>
<pre class="prettyprint" data-lang="JavaScript">
function <b>signinCallback(authResult)</b> {
<b>if (authResult['access_token']) {
// Successfully authorized
}</b> else if (authResult['error']) {
// User is not signed in.
}
}
</pre>
</article>
<img class="corner-placemark" src="images/client-auth.png" class="reflect" alt="Client Auth" title="Client Auth">
</slide>
<slide class="segue dark nobackground">
<aside class="gdbar"><img src="images/google_developers_icon_128.png"></aside>
<hgroup class="auto-fadein">
<h2>Server Auth: How to connect your app server with Google</h2>
</hgroup>
</slide>
<slide>
<hgroup>
<h2>Server Auth</h2>
</hgroup>
<article class="larger" style="float: left; width: 35%">
<ul>
<li>iOS</li>
<li>Android</li>
<li>Web</li>
</ul>
</article>
<article style="float:right; width:60%; margin-top: 75px;">
<img width="100%" src="images/server-auth.png" class="reflect" alt="Server Auth" title="Server Auth"><br />
</article>
</slide>
<slide>
<hgroup>
<h2>iOS Auth To Server</h2>
<h3>Send Access Token To Server</h3>
</hgroup>
<article>
<ul>
<li>Send tokens securely</li>
<li>Access Tokens are bearer tokens and anyone can use them</li>
<li>Access Tokens last one hour</li>
</ul>
<pre class="prettyprint" data-lang="Objective-C">
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
<b>NSString *accessToken = auth.accessToken;</b>
if (error) {
signInAuthStatus_.text =
[NSString stringWithFormat:@"Status: Authentication error: %@", error];
return;
}
[self reportAuthStatus];
}
</pre>
</article>
<img class="corner-placemark" src="images/server-auth.png" class="reflect" alt="Server Auth" title="Server Auth">
</slide>
<slide>
<hgroup>
<h2>Android Auth To Server</h2>
<h3>Send Access Token To Server</h3>
</hgroup>
<article>
<ul>
<li>Send tokens securely</li>
<li>Access Tokens are bearer tokens and anyone can use them</li>
<li>Access Tokens last one hour</li>
</ul>
<pre class="prettyprint" data-lang="Android">
try {
<b>String access_token = GoogleAuthUtil.getToken(this,
mPlusClient.getAccountName(),
"oauth2:" + TextUtils.join(' ', SCOPES));</b>
} catch (UserRecoverableAuthException e) {
// Recover
} catch (Exception e) {
throw new RuntimeException(e);
}
</pre>
</article>
<img class="corner-placemark" src="images/server-auth.png" class="reflect" alt="Server Auth" title="Server Auth">
</slide>
<slide>
<hgroup>
<h2>Server: Verify Access Token</h2>
</hgroup>
<article>
<pre class="prettyprint" data-lang="Python">
import httplib2
import json
<b>url = ('https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=%s'
% access_token)</b>
h = httplib2.Http()
result = json.loads(h.request(url, 'GET')[1])
# If there was an error in the access token info, abort.
<b>if result.get('error') is not None:</b>
return
# Verify that the access token is valid for this app.
<b>if result['issued_to'] != CLIENT_ID:</b>
return
# Get the user ID.
gplus_id = result['user_id']
</pre>
</article>
<img class="corner-placemark" src="images/server-auth.png" class="reflect" alt="Server Auth" title="Server Auth">
</slide>
<slide>
<hgroup>
<h2>Android Auth To Server</h2>
<h3>Send One-Time Authorization Code<h3>
</hgroup>
<article>
<ul>
<li>Code can only be used by your server</li>
<li>Code can get an Access Token and a Refresh Token</li>
<li>Refresh Tokens do not expire</li>
</ul>
<pre class="prettyprint" data-lang="Android">
try {
<b>String code = GoogleAuthUtil.getToken(this,
mPlusClient.getAccountName(),
"oauth2:server:client_id:" + CLIENT_ID
+ ":api_scope:" + TextUtils.join(' ', SCOPES));</b>
} catch (UserRecoverableAuthException e) {
// Recover
} catch (Exception e) {
throw new RuntimeException(e);
}
</pre>
</article>
<img class="corner-placemark" src="images/server-auth.png" class="reflect" alt="Server Auth" title="Server Auth">
</slide>
<slide>
<hgroup>
<h2>Web Auth To Server</h2>
<h3>Send One-Time Authorization Code<h3>
</hgroup>
<article>
<ul>
<li>Code can only be used by your server</li>
<li>Code can get an Access Token and a Refresh Token</li>
<li>Refresh Tokens do not expire</li>
</ul>
<pre class="prettyprint" data-lang="JavaScript">
function signinCallback(authResult) {
if (authResult['access_token']) {
<b>// Send code to server in POST request
var code = authResult.code;</b>
} else if (authResult['error']) {
// User is not signed in.
}
}
</pre>
</article>
<img class="corner-placemark" src="images/server-auth.png" class="reflect" alt="Server Auth" title="Server Auth">
</slide>
<slide>
<hgroup>
<h2>Server: Exchange Authorization Code</h2>
</hgroup>
<article class="flexbox vcenter">
<pre class="prettyprint" data-lang="Ruby">
$authorization.code = request.body.read
<b>$authorization.fetch_access_token!</b>
</pre>
<pre class="prettyprint" data-lang="Python">
code = request.data
<b>credentials = oauth_flow.step2_exchange(code)</b>
</pre>
<pre class="prettyprint" data-lang="PHP">
$code = $request->getContent();
<b>$client->authenticate($code);</b>
</pre>
Full code, including Java and C#/.NET, available in our Quickstarts
</article>
<img class="corner-placemark" src="images/server-auth.png" class="reflect" alt="Server Auth" title="Server Auth">
</slide>
<slide>
<hgroup>
<h2>Ways To Enable Server-Side Auth</h2>
</hgroup>
<article style="margin-top: 60px;">
<table style="font-size: 280%;">
<tr>
<th style="font-size: 50%"></th>
<th style="font-size: 50%">iOS</th>
<th style="font-size: 50%">Android</th>
<th style="font-size: 50%">Web</th>
</tr>
<tr>
<td style="font-size: 40%">Verify Access Token</td>
<td style="font-size: 40%"><font color="green">✓</font></td>
<td style="font-size: 40%"><font color="green">✓</font></td>
<td style="font-size: 40%"><font color="green">✓</font></td>
</tr>
<tr>
<td style="font-size: 40%">Exchange One-Time Code *</td>
<td style="font-size: 40%">-</td>
<td style="font-size: 40%"><font color="green">✓ (new)</font></td>
<td style="font-size: 40%"><font color="green">✓</font></td>
</tr>
</table>
<p><p>
* The one-time code can retrieve a refresh token if you ask for offline access
</article>
<img class="corner-placemark" src="images/server-auth.png" class="reflect" alt="Server Auth" title="Server Auth">
</slide>
<slide>
<hgroup>
<h2>Multiple Auth Systems</h2>
<h3>Proprietary password, Google+, Facebook</h3>
</hgroup>
<article style="float: left; width: 70%">
<ul>
<li>Trickier to support multiple-auth systems</li>
<ul>
<li>e.g Need to consider ways to merge user identities across different systems</li>
</ul>
<li>Talk by Ian Barber</li>
<ul>
<li><b>How to Offer Google+ Sign-In Alongside Other Social Sign-In Services</b></li>
</ul>
</ul>
</article>
<article style="float:right; width:25%; margin-top: 180px">
<img width="200px" src="images/ian-barber.jpg" class="reflect" alt="Ian Barber" title="Ian Barber"><br />
</article>
</slide>
<slide>
<hgroup>
<h2>Review</h2>
<h3>Cross-Platform Auth with Google+ Sign-In</h3>
</hgroup>
<article>
<ul>
<li>Do not build your own authentication system</li>
<li>Google+ makes authentication easy</li>
<li>Auth models depend on your architecture</li>
<li>Learn more and check out our Quickstarts and PhotoHunt at
<a href="https://developers.google.com/+/">https://developers.google.com/+/</a> and
<a href="https://developers.google.com/+/">https://github.com/googleplus</a>
</li>
</ul>
</article>
</slide>
<slide class="thank-you-slide segue nobackground">
<aside class="gdbar right"><img src="images/google_developers_icon_128.png"></aside>
<article class="flexbox vleft auto-fadein">
<h2><Thank You!></h2>
<h3>Q&A <a style="color: white;" href="http://goo.gl/48LOh">http://goo.gl/48LOh</a>
<p>developers.google.com/+</p>
</article>
<p class="auto-fadein" data-config-contact>
<!-- populated from slide_config.json -->
</p>
</slide>
<slide class="logoslide dark nobackground">
<article class="flexbox vcenter">
<span><img src="images/google_developers_logo_white.png"></span>
</article>
</slide>
<slide class="backdrop"></slide>
</slides>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!--[if IE]>
<script src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
<script>CFInstall.check({mode: 'overlay'});</script>
<![endif]-->
</body>
</html>