Google+ API
#GDG #DevFestJkt #DevFest #2012
Oon Arfiandwi <oon@7langit.com>
Manager of Google Developer Group Jakarta
http://gplus.to/oonid
so, what can be covered
in 35 mins?
Google+ API in general
OAuth2.0 + REST API
Sign in with Google+, get to know about
People, Activities & Comments
Let’s code in Android + Google Play Services
Google+ History
Google+ API
http://developers.google.com/+
Plugins for your website + REST API
Mobile Platform (Android, iOS, mobile web)
Hangout API
History API (developer preview)
OAuth 2.0
Generate OAuth 2.0 Token
via Google Play Services
GoogleAuthUtil.getToken()
via Google APIs Client Library for Java
create API Project with Google APIs Console
open browser to URL from GoogleAuthorizationCodeRequestURL
get Token via execute GoogleAuthorizationCodeTokenRequest
Activate Service:
Google+ API
Google+ History API
Create:
OAuth 2.0 client ID
Google APIs Console
String googleAuthorizationCodeRequestUrl = new GoogleAuthorizationCodeRequestUrl(
	 	 ShrdPrfsStore.CLIENT_ID,ShrdPrfsStore.REDIRECT_URI,ShrdPrfsStore.SCOPE).build();
	
	webview.setWebViewClient(new WebViewClient() {
		 @Override
		 public void onPageFinished(WebView view, String url) {
		 	 if (url.startsWith(SharedPrefsStore.REDIRECT_URI)) {
	 	 	 	 try {
	 	 	 	 	 if (url.indexOf("code=") != -1) {
	 	 	 	 	 	 // Url is like http://localhost/?code=4/Z5DgC1IxNL-muPsrE2Sjy9zQn2pF
	 	 	 	 	 	 String code = url.substring...
	 	 	 	 	 	 TokenResponse accessTokenResponse =
new GoogleAuthorizationCodeTokenRequest(
	 	 	 	 	 	 	 new NetHttpTransport(), new JacksonFactory(),
	 	 	 	 	 	 	 ShrdPrfsStore.CLIENT_ID, ShrdPrfsStore.CLIENT_SECRET,
	 	 	 	 	 	 	 code, ShrdPrfsStore.REDIRECT_URI).execute();
	 	 	 	 	 	 ...
	 	 	 	 	 	 credentialStore.write(accessTokenResponse);
	 	 	 	 	 	 ...
	 	 	 	 	 }
	 	 	 	 } catch (IOException e) {}
	 	 	 }
		 };
	});
	webview.loadUrl(googleAuthorizationCodeRequestUrl);
OAuth 2.0 login with
Google+ Account
Registered Product Name:
DevFestJktPro
SCOPE:
plus.me
plus.moment.write
“Public”
A
ctivities
Access Google+ Activities
using OAuth access token
as GoogleCredential
Filter the Google+
Activities by user and
collections (eg: “public”)
Create Simple ListView
based on Google+ Activity
Titles
Google+ History API
http://developers.google.com/+/history/preview/
“Google+ history is a collection of moments that
describe activities the user has engaged across the web
and apps.”
Google+ history API privately save moments, users can
share those moments with others.
Moments in History
Types of Moments
AddActivity
BuyActivity
CheckInActivity
ListenActivity
ReviewActivity ...
Moments target URL
must include
attribute from
schema.org markup
Request new type of
Moments?
G
oogle+
H
istory
Google+ History preview
user interface, available for
registered developer
History of CheckInActivity
History of AddActivity (+1)
Google+ API
The end
or is it the beginning?
(quote from G+ History)
Questions?

Google+ API (2012)

  • 1.
    Google+ API #GDG #DevFestJkt#DevFest #2012 Oon Arfiandwi <oon@7langit.com> Manager of Google Developer Group Jakarta http://gplus.to/oonid
  • 2.
    so, what canbe covered in 35 mins? Google+ API in general OAuth2.0 + REST API Sign in with Google+, get to know about People, Activities & Comments Let’s code in Android + Google Play Services Google+ History
  • 3.
    Google+ API http://developers.google.com/+ Plugins foryour website + REST API Mobile Platform (Android, iOS, mobile web) Hangout API History API (developer preview)
  • 4.
    OAuth 2.0 Generate OAuth2.0 Token via Google Play Services GoogleAuthUtil.getToken() via Google APIs Client Library for Java create API Project with Google APIs Console open browser to URL from GoogleAuthorizationCodeRequestURL get Token via execute GoogleAuthorizationCodeTokenRequest
  • 5.
    Activate Service: Google+ API Google+History API Create: OAuth 2.0 client ID Google APIs Console
  • 6.
    String googleAuthorizationCodeRequestUrl =new GoogleAuthorizationCodeRequestUrl( ShrdPrfsStore.CLIENT_ID,ShrdPrfsStore.REDIRECT_URI,ShrdPrfsStore.SCOPE).build(); webview.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { if (url.startsWith(SharedPrefsStore.REDIRECT_URI)) { try { if (url.indexOf("code=") != -1) { // Url is like http://localhost/?code=4/Z5DgC1IxNL-muPsrE2Sjy9zQn2pF String code = url.substring... TokenResponse accessTokenResponse = new GoogleAuthorizationCodeTokenRequest( new NetHttpTransport(), new JacksonFactory(), ShrdPrfsStore.CLIENT_ID, ShrdPrfsStore.CLIENT_SECRET, code, ShrdPrfsStore.REDIRECT_URI).execute(); ... credentialStore.write(accessTokenResponse); ... } } catch (IOException e) {} } }; }); webview.loadUrl(googleAuthorizationCodeRequestUrl);
  • 7.
    OAuth 2.0 loginwith Google+ Account Registered Product Name: DevFestJktPro SCOPE: plus.me plus.moment.write
  • 8.
    “Public” A ctivities Access Google+ Activities usingOAuth access token as GoogleCredential Filter the Google+ Activities by user and collections (eg: “public”) Create Simple ListView based on Google+ Activity Titles
  • 9.
    Google+ History API http://developers.google.com/+/history/preview/ “Google+history is a collection of moments that describe activities the user has engaged across the web and apps.” Google+ history API privately save moments, users can share those moments with others.
  • 10.
    Moments in History Typesof Moments AddActivity BuyActivity CheckInActivity ListenActivity ReviewActivity ... Moments target URL must include attribute from schema.org markup Request new type of Moments?
  • 11.
    G oogle+ H istory Google+ History preview userinterface, available for registered developer History of CheckInActivity History of AddActivity (+1)
  • 12.
    Google+ API The end oris it the beginning? (quote from G+ History) Questions?