SlideShare a Scribd company logo
Cross-Platform Auth
with Google+ Sign-In
Google+ Platform
Peter Friese - Developer Advocate
Peter Friese - Developer Advocate
+PeterFriese
@peterfriese
http://www.peterfriese.de
What is Google+ ?
https://www.flickr.com/photos/dainbinder/10538549606/
http://openclipart.org/detail/26329/aiga-immigration-bg-by-anonymous
What is Authentication?
What is Authentication?
αὐθεντικός (greek):
!
“that comes from the author” /
authentic /original /genuine
Authentication:
!
The act of confirming the truth of
an attribute of a datum or an
entity.
datum or an entity.
Authentication Factors
Ownership Knowledge Inherence
https://www.flickr.com/photos/europealacarte/9152848988/ https://www.flickr.com/photos/gcfairch/3595771919/https://www.flickr.com/photos/z0/5055081370/
Authentication - How hard can it be?
https://www.flickr.com/photos/isherwoodchris/7018779395/
Quite hard, actually!
https://www.flickr.com/photos/govwin/5609940697/
Things to consider
• Encrypt traffic
• Hash + salt passwords
• Two-factor auth
• Account recovery
http://upload.wikimedia.org/wikipedia/commons/4/41/Space_Shuttle_Columbia_launching.jpg
You might end up in the News
On the shoulders of Giants…
https://www.flickr.com/photos/govwin/5609940697/
Use an identity provider
• Easier for you
• Easier for the user
• Established, trusted brand
• Focus on your business model
(rather than re-inventing the wheel)
http://www.nasa.gov/centers/dryden/images/content/690557main_SCA_Endeavour_over_Ventura.jpg
±

KEEP CALM

AND

SIGN IN

WITH

GOOGLE+
Google+ Sign-in Features
Google: trusted brand
2-factor verification, using your phone
Works alongside existing sign-in systems
Secure Authentication
Google+ Sign-in Features
Learn more about your users (with their consent)
Sign-in to web site
Cross-Device Single Sign-on and Over-the-Air Install (OTA)
Google+ Sign-in Features
Sign-in to web site
Cross-Device Single Sign-on and Over-the-Air Install (OTA)
Google+ Sign-in Features
Sign-in to web site
Cross-Device Single Sign-on and Over-the-Air Install (OTA)
Google+ Sign-in Features
Sign-in to web site
Cross-Device Single Sign-on and Over-the-Air Install (OTA)
Google+ Sign-in Features
OTA consent dialog
Sign-in to web site
Cross-Device Single Sign-on and Over-the-Air Install (OTA)
Google+ Sign-in Features
OTA consent dialog
OTA installation
Sign-in to web site
Cross-Device Single Sign-on and Over-the-Air Install (OTA)
Google+ Sign-in Features
OTA consent dialog
OTA installation
Sign-in to web site
Cross-Device Single Sign-on and Over-the-Air Install (OTA)
Google+ Sign-in Features
OTA consent dialog
OTA installation
Auto signed in on other device
Sign-in to web site
Cross-Device Single Sign-on and Over-the-Air Install (OTA)
Google+ Sign-in Features
OTA consent dialog
OTA installation
Auto signed in on other device
How does Google+ Sign-in work?
AppUser
Google
Based on OAuth 2.0
How does Google+ Sign-in work?
Consent Permission
AppUser
Google
Based on OAuth 2.0
How does Google+ Sign-in work?
Consent Permission
No password sharing
Scoped access
Revocable
Implementing Google+ Sign-in
Developer Console Project
Setting up
https://developers.google.com/console
APIs
Credentials
iOS Client ID
Android Client ID
Web Client ID
Branding
Permissions
Management
Developer Console Project
Setting up
https://developers.google.com/console
APIs
Credentials
iOS Client ID
Android Client ID
Web Client ID
Branding
Permissions
Management
One project, multiple clients
Developer Console Project
Setting up
https://developers.google.com/console
APIs
Credentials
iOS Client ID
Android Client ID
Web Client ID
Branding
Permissions
Management
One project, multiple clients
Authorization is granted to
your application, not a specific
client!
* Single user consent across
devices
* Cross-Device Single Sign-on
* Available for Web &
Android
You Google
The Auth Triangle
Connecting lines
need authentication
Client
Server
Google APIs
You Google
Client
Server
Google APIs
Client Authentication
Client Authentication
Create OAuth 2.0 client ID
Link with Google Play Services API
Setup Sign-In
Overview
Client Authentication: Android
SDK Architecture
Client Authentication: Android
iOS
Your App
Google APIs
Google Play
Client Library
Google Play
Services APK
Authorize using existing
accounts on Android device
mApiClient = new GoogleApiClient.Builder(this)	
.addConnectionCallbacks(this)	
.addOnConnectionFailedListener(this)	
.addApi(Plus.API, null)	
.addScope(Plus.SCOPE_PLUS_LOGIN)	
.build();
Java
GoogleApiClient Lifecycle
Client Authentication: Android
onCreate()
onStart() mApiClient.connect();
Java
onStop()
if (mApiClient.isConnected()) {	
mApiClient.disconnect();	
}
Java
<com.google.android.gms.common.SignInButton	
android:id="@+id/sign_in_button"	
android:layout_width="wrap_content"	
android:layout_height="wrap_content"/>
XML
running
Handle connection failure
Client Authentication: Android
public void onConnectionFailed(ConnectionResult result) {	
	 if (!mIntentInProgress && result.hasResolution()) {	
	 	 try {	
	 	 	 mIntentInProgress = true;	
	 	 	 startIntentSenderForResult(result.getResolution().getIntentSender(),	
	 	 	 	 	 RC_SIGN_IN, null, 0, 0, 0);	
	 	 } catch (SendIntentException e) {	
	 	 	 // The intent was canceled before it was sent. Return to the default	
	 	 	 // state and attempt to connect to get an updated ConnectionResult.	
	 	 	 mIntentInProgress = false;	
	 	 	 mApiClient.connect();	
	 	 }	
	 }	
}	
Java
Handle connection failure
Client Authentication: Android
public void onConnectionFailed(ConnectionResult result) {	
	 if (!mIntentInProgress && result.hasResolution()) {	
	 	 try {	
	 	 	 mIntentInProgress = true;	
	 	 	 startIntentSenderForResult(result.getResolution().getIntentSender(),	
	 	 	 	 	 RC_SIGN_IN, null, 0, 0, 0);	
	 	 } catch (SendIntentException e) {	
	 	 	 // The intent was canceled before it was sent. Return to the default	
	 	 	 // state and attempt to connect to get an updated ConnectionResult.	
	 	 	 mIntentInProgress = false;	
	 	 	 mApiClient.connect();	
	 	 }	
	 }	
}	
Java
User needs to select account, consent to permissions, ensure
network connectivity, etc. to connect
Connection successful
Client Authentication: Android
public void onConnected(Bundle connectionHint) { 	
	 // Retrieve some profile information to personalize our app for the user.	
	 Person currentUser = Plus.PeopleApi.getCurrentPerson(mApiClient);	
	
	 // Indicate that the sign in process is complete.	
	 mSignInProgress = STATE_DEFAULT;	
}
Java
Create OAuth 2.0 client ID
Integrate SDK
Setup Sign-In
Overview
Client Authentication: iOS
iOS
Your App
Google APIs
Google+
iOS SDK
SDK Architecture
Client Authentication: iOS
Statically linked library
#import <GooglePlus/GooglePlus.h>
#import <GoogleOpenSource/GoogleOpenSource.h>
!
...
!
!
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGoogleUserEmail = YES;
!
signIn.clientID = @“YOUR_CLIENT_ID”;
signIn.scopes = @[@"profile"];
signIn.delegate = self;
Objective-C
Configure Sign-In
Client Authentication: iOS
Perform Sign-In, Option 1 (use our button)
Client Authentication: iOS
Create own button / use action sheet / …
// trigger sign-in
[[GPPSignIn sharedInstance] authenticate];
Objective-C
Silent sign-in if user has signed in before:
// silently sign in
[[GPPSignIn sharedInstance] trySilentAuthentication];
Objective-C
Perform Sign-In, Option 2 (create your own button)
Client Authentication: iOS
Receiving the authorisation
Client Authentication: iOS
// In ApplicationDelegate
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
return [GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
!
!
// GPPSignInDelegate
- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error
{
if (!error) {
NSString *gplusId = [GPPSignIn sharedInstance].userID;
}
}
Objective-C
Create OAuth 2.0 client ID
Include JavaScript client on your web page
Add Google+ Sign-in button
Handle callback
Overview
Client Authentication: Web
Browser
Your site
Google APIsplusone.js
Architecture
Client Authentication: Web
<div id="gConnect">
<button class="g-signin"
data-scope="https://www.googleapis.com/auth/plus.login"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-clientId="YOUR_CLIENT_ID"
data-callback="onSignInCallback"
data-cookiepolicy="single_host_origin">
</button>
</div>
!
<!-- Place plusone.js asynchronous JavaScript just before your </body> tag —>
HTML
Integrate sign-in button
Client Authentication: Web
function onSignInCallback(authResult) {
if (authResult['access_token']) {
// Successfully authorized
} else if (authResult['error']) {
// User is not signed in.
}
}
JavaScript
Handle authorization callback
Client Authentication: Web
Server Authentication
You Google
Client
Server
Google APIs
One-Time-Code Flow
C
li
e
n
t
S
e
r
v
e
r
Google
APIs
1: Client-side auth request
2: OAuth dialog
triggeredOAuth
2.0
Dialog
3: access_token,
one-time code,
id_token
4: one-time code 5: exchange one-time codefor access_token andrefresh_token
6: access_token,
refresh_token
7: “fully logged in”
<div id="gConnect">
<button class="g-signin"
data-scope="https://www.googleapis.com/auth/plus.login"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-clientId="YOUR_CLIENT_ID"
data-callback="onSignInCallback"
data-cookiepolicy=“single_host_origin">
data-callback="signInCallback">
</button>
</div>
!
<!-- Place plusone.js asynchronous JavaScript just before your </body> tag —>
HTML
Integrate sign-in button
Server Auth: One-Time Code
function signInCallback(authResult) {
if (authResult['code']) {
// Send the code to the server
$.ajax({
type: 'POST',
url: 'plus.php?storeToken',
contentType: 'application/octet-stream; charset=utf-8',
success: function(result) {
// Handle or verify the server response if necessary.
console.log(result);
} else {
$('#results').html('Failed to make a server-side call.');
}
},
processData: false,
data: authResult['code']
});
} else if (authResult['error']) {
console.log('There was an error: ' + authResult['error']);
}
}
JavaScript
Handle authorization callback
Server Auth: One-Time Code
$code = $request->getContent();
!
// Exchange the OAuth 2.0 authorization code for user credentials.
$client->authenticate($code);
!
$token = json_decode($client->getAccessToken());
!
// Verify the token
...
!
// Store the token in the session for later use.
$app['session']->set('token', $client->getAccessToken());
$response = 'Successfully connected with token: ' . print_r($token, true);
PHP
Exchange one-time code
Server Auth: One-Time Code
Best practices and Common Pitfalls
Best practices and Common Pitfalls
Common Pitfalls
Guidelines
Best practices
Useful resources
Guidelines
• Use our client libraries (they’re well debugged) instead of rolling your
own HTTP requests
• Provide a way for the user to sign out / disconnect your app
• Use “Sign in with Google” when labelling your sign in buttons. Don’t use
“Sign in with Google+”
• Equal rights to everyone: sign-in buttons should be equally sized for all
networks you support
• Ask only for permissions you really need. Also, consider using
incremental auth - this will likely increase sign-up rates.
Pitfalls: iOS
• Not providing a URL type for callback
• Not providing the ApplicationDelegate
application:openURL:sourceApplication:
annotation: callback or failing to call
GPPURLHandler
handleURL:sourceApplication:annotation
Best practices and Common Pitfalls
deprecated)
Use Stop using
profile
(for basic login)
https://www.googleapis.com/auth/userinfo.profile
plus.login
(if you need more info about a user. Includes profile)
email
(the user’s email address)
https://www.googleapis.com/auth/userinfo.email
Useful resources
• Scopes

https://developers.google.com/+/api/oauth#scopes
• Developer Console

https://console.developers.google.com/project
• OAuth 2.0 Playground

https://developers.google.com/oauthplayground/
• Tokeninfo

https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=
Review
• Do not build your own authentication system
• Google+ makes authentication easy
• Authentication models depends on architecture
• Learn more: check out our Quickstarts at 

https://developers.google.com/+/ and 

https://github.com/googleplus
Cross-Platform Auth With Google+ Sign-in
Review
<Thank You!>
developers.google.com/+
Peter Friese - Developer Advocate
+PeterFriese
@peterfriese
http://www.peterfriese.de

More Related Content

PDF
Google+ for Mobile Apps on iOS and Android
PDF
The Glass Class - Tutorial 2 - Mirror API
PDF
Pocket Authentication with OAuth on Firefox OS
PDF
Vaadin DevDay 2017 - DI your UI
PDF
What's new in Android Wear 2.0
KEY
Design Patterns for Tablets and Smartphones
PDF
Android best practices
PPT
OpenSocial Intro
Google+ for Mobile Apps on iOS and Android
The Glass Class - Tutorial 2 - Mirror API
Pocket Authentication with OAuth on Firefox OS
Vaadin DevDay 2017 - DI your UI
What's new in Android Wear 2.0
Design Patterns for Tablets and Smartphones
Android best practices
OpenSocial Intro

What's hot (16)

PDF
Introduction to Android Wear
PDF
Vaadin Components
PDF
Vaadin Components @ Angular U
KEY
2011 a grape odyssey
PDF
Android ui layouts ,cntls,webservices examples codes
PDF
Building web apps with vaadin 8
PDF
Android in practice
PDF
Android Data Binding in action using MVVM pattern - droidconUK
PPTX
Facebook Apps Development 101 (Java)
PDF
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
PPT
Android the Agile way
PDF
Gdg san diego android 11 meetups what's new in android - ui and dev tools
PPTX
iOS and Android apps automation
PPTX
jQuery Ecosystem
PDF
Vue.js part1
PDF
Static Reference Analysis for GUI Objects in Android Software
Introduction to Android Wear
Vaadin Components
Vaadin Components @ Angular U
2011 a grape odyssey
Android ui layouts ,cntls,webservices examples codes
Building web apps with vaadin 8
Android in practice
Android Data Binding in action using MVVM pattern - droidconUK
Facebook Apps Development 101 (Java)
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
Android the Agile way
Gdg san diego android 11 meetups what's new in android - ui and dev tools
iOS and Android apps automation
jQuery Ecosystem
Vue.js part1
Static Reference Analysis for GUI Objects in Android Software
Ad

Similar to Cross-Platform Authentication with Google+ Sign-In (20)

PPTX
Google+ sign in for mobile & web apps
PDF
Introduction to Web APIs and the Google+ API - BarCamp Phnom Penh 2011
PDF
OAuth 2.0
PDF
AdWords API and OAuth 2.0
PPTX
Saas webinar-dec6-01
PDF
Google+ Login - A Primer
PPTX
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
PDF
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
PDF
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
PDF
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
PPTX
OAuth - Don’t Throw the Baby Out with the Bathwater
PPTX
API Management and Mobile App Enablement
PPT
Oauth2.0
PDF
google drive and the google drive sdk
KEY
2011 august-gdd-mexico-city-rest-json-oauth
PDF
Mobile SSO: Give App Users a Break from Typing Passwords
PPTX
A recipe for standards-based Cloud IdM
PPTX
CIS 2012 - Going Mobile with PingFederate and OAuth 2
PDF
What the Heck is OAuth and OIDC - Denver Developer Identity Workshop 2020
PDF
Centralise legacy auth at the ingress gateway, SREday
Google+ sign in for mobile & web apps
Introduction to Web APIs and the Google+ API - BarCamp Phnom Penh 2011
OAuth 2.0
AdWords API and OAuth 2.0
Saas webinar-dec6-01
Google+ Login - A Primer
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
OAuth - Don’t Throw the Baby Out with the Bathwater
API Management and Mobile App Enablement
Oauth2.0
google drive and the google drive sdk
2011 august-gdd-mexico-city-rest-json-oauth
Mobile SSO: Give App Users a Break from Typing Passwords
A recipe for standards-based Cloud IdM
CIS 2012 - Going Mobile with PingFederate and OAuth 2
What the Heck is OAuth and OIDC - Denver Developer Identity Workshop 2020
Centralise legacy auth at the ingress gateway, SREday
Ad

More from Peter Friese (20)

PDF
Building Reusable SwiftUI Components
PDF
Firebase & SwiftUI Workshop
PDF
Building Reusable SwiftUI Components
PDF
Firebase for Apple Developers - SwiftHeroes
PDF
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
PDF
async/await in Swift
PDF
Firebase for Apple Developers
PDF
Building Apps with SwiftUI and Firebase
PDF
Rapid Application Development with SwiftUI and Firebase
PDF
Rapid Application Development with SwiftUI and Firebase
PDF
6 Things You Didn't Know About Firebase Auth
PDF
Five Things You Didn't Know About Firebase Auth
PDF
Building High-Quality Apps for Google Assistant
PDF
Building Conversational Experiences with Actions on Google
PDF
Building Conversational Experiences with Actions on Google
PDF
Google Fit, Android Wear & Xamarin
PDF
Introduction to Android Wear
PDF
Google Play Services Rock
PDF
Bring Back the Fun to Testing Android Apps with Robolectric
PDF
Do Androids Dream of Electric Sheep
Building Reusable SwiftUI Components
Firebase & SwiftUI Workshop
Building Reusable SwiftUI Components
Firebase for Apple Developers - SwiftHeroes
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
async/await in Swift
Firebase for Apple Developers
Building Apps with SwiftUI and Firebase
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and Firebase
6 Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase Auth
Building High-Quality Apps for Google Assistant
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google
Google Fit, Android Wear & Xamarin
Introduction to Android Wear
Google Play Services Rock
Bring Back the Fun to Testing Android Apps with Robolectric
Do Androids Dream of Electric Sheep

Recently uploaded (20)

PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Machine learning based COVID-19 study performance prediction
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
Teaching material agriculture food technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Cloud computing and distributed systems.
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Machine learning based COVID-19 study performance prediction
Review of recent advances in non-invasive hemoglobin estimation
Teaching material agriculture food technology
MIND Revenue Release Quarter 2 2025 Press Release
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Encapsulation theory and applications.pdf
MYSQL Presentation for SQL database connectivity
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Network Security Unit 5.pdf for BCA BBA.
Cloud computing and distributed systems.
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The AUB Centre for AI in Media Proposal.docx
NewMind AI Weekly Chronicles - August'25 Week I
Advanced methodologies resolving dimensionality complications for autism neur...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation_ Review paper, used for researhc scholars

Cross-Platform Authentication with Google+ Sign-In