google app engine google apis oauth facebook graph api

28
Google App Engine Google APIs OAuth Facebook Graph API Google Developer Group Presentation & Workshop @ Albertian Institute of Science & Technology – 19 th October 2013 Shashidhar Gurumurthy [email protected] https://cloud.google.com/ Twitter Bootstra

Upload: rhys

Post on 23-Feb-2016

97 views

Category:

Documents


0 download

DESCRIPTION

Google App Engine Google APIs OAuth Facebook Graph API. Twitter Bootstrap. Google Developer Group Presentation & Workshop @ Albertian Institute of Science & Technology – 19 th October 2013 Shashidhar Gurumurthy [email protected]. https://cloud.google.com/. Agenda. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Google App  Engine Google APIs OAuth Facebook Graph  API

Google App EngineGoogle APIs

OAuthFacebook Graph API

Google Developer Group Presentation & Workshop @ Albertian Institute of Science & Technology – 19th October 2013Shashidhar Gurumurthy [email protected]

https://cloud.google.com/

Twitter Bootstrap

Page 2: Google App  Engine Google APIs OAuth Facebook Graph  API

2

Agenda Session Objectives App Engine Overview Environment Setup App Engine Services OAuth Google APIs Facebook APIs References

Play on shashi-demo.appspot.com

Page 3: Google App  Engine Google APIs OAuth Facebook Graph  API

3

Session Objectives Describe App Engine & its offerings Get you started on App Engine development

using Java Usage of commonly used App Engine services OAuth Working with Google APIs Working with Facebook APIs Help you develop your first App Engine

application and use few Google & Facebook APIs

Objectives

Page 4: Google App  Engine Google APIs OAuth Facebook Graph  API

4

Session Objectives – Prerequisites Familiarity with Servlet development using a

Servlet container such as Tomcat is assumed Some familiarity with Eclipse IDE

That’s it… that’s all you need to get started on developing awesome apps with Google App Engine.

Objectives

Page 5: Google App  Engine Google APIs OAuth Facebook Graph  API

5

Session Objectives – What’s not covered Google App Engine applications can be written

in Python and Go programming languages as well. This session uses Java.

All Services provided are not covered due to time constraints

Objectives

Page 6: Google App  Engine Google APIs OAuth Facebook Graph  API

6

So… what is Google App Engine Google App Engine lets you:

Run web applications on Google’s infrastructureEasy to build, maintain and scaleNo servers to maintain – just upload your applicationCosts nothing to get started:

○ All applications get a free limit on resources○ When billing is enabled for an application, free limits are raised but

you still pay only for resource usage above free levels Applications run in a secure environment with limited

access to underlying operating systemApplications can only access other computers on the internet

through provided URL Fetch and Email servicesApplications cannot write to the file systemsApplication code only runs in response to a web request, queued

task or a scheduled task

Overview

Page 7: Google App  Engine Google APIs OAuth Facebook Graph  API

7

The Java Runtime Environment Java runtime environment uses Java 6 (Java 7

support is experimental with SDK 1.7.5+) App Engine Java SDK supports Java 5 or 6 Java Servlet and JSPs The SDK provides implementations of Java Data

Objects (JDO) & Java Persistence API (JPA) interfaces for interaction with App Engine Datastore

JavaMail API can be used to send mail with App Engine Mail service

java.net.HTTP APIs access the App Engine URL Fetch service

Overview

Page 8: Google App  Engine Google APIs OAuth Facebook Graph  API

8

Development Workflow App Engine SDK includes tools for local emulation

of App Engine services SDK includes tools for uploading application to App

Engine The App Engine admin console is the web-based

interface for managing applications running on the App Engine. Use it to:Create new appsConfigure domain namesChange which version of application is liveExamine logsBrowse application datastoreView Memcache

Overview

App Engine Console

Page 9: Google App  Engine Google APIs OAuth Facebook Graph  API

9

Environment Setup Install Java SDK (1.7 or 1.6) – 1.7 is

experimental and available on App Engine SDK 1.7.5+ only

If using Eclipse, install Google Plugin for Eclipse If not using Eclipse, download App Engine Java

SDKIn this case you will also need Apache Ant to enable

you to interact with App Engine via command line interface – we will not cover this case.

Setup details: https://developers.google.com/appengine/docs/java/gettingstarted/installing

Setup

App Engine Information on web

Page 10: Google App  Engine Google APIs OAuth Facebook Graph  API

10

Services – Users App Engine applications can authenticate using

one of three methods:Google AccountsAccounts on Google Apps DomainsOpenID identifier – federated authentication

Application can access a signed in user’s email address (or OpenID identifier)

The app can detect whether the current user is an administrator

Services

Page 11: Google App  Engine Google APIs OAuth Facebook Graph  API

11

Services – Datastore The App Engine Datastore is a schemaless object

datastore The Datastore holds data objects known as entities Each entity is identified by its kind which categorizes

the entity for the purpose of queries, and a key that uniquely identifies it within its kind

The Datastore can execute multiple operations in a single transaction

While the Datastore interface has similar features as traditional relational databases, it differs in the way it describes relationships between data objects

Entities of the same kind can have different properties

Services

Page 12: Google App  Engine Google APIs OAuth Facebook Graph  API

12

Services – Java Datastore API The App Engine Java SDK provides a low-level

Datastore API with simple operations on entities The SDK also includes implementation of the

Java Data Objects (JDO) and Java Persistence API (JPA) interfaces for modeling and persisting data

App Engine Datastore service is a large area of study

We will briefly review JDO for persisting and querying entities

Services

Page 13: Google App  Engine Google APIs OAuth Facebook Graph  API

13

Services – Scheduled Tasks The App Engine Cron Service allows

scheduling of tasks that operate at defined times or regular intervals

A Cron job will invoke a URL using an HTTP GET request at a given time of day

A cron.xml file in WEB-INF directory of the application controls cron

The Admin Console allows you to view the state of your cron jobs

The dev appserver does not automatically run the cron jobs

Services

Page 14: Google App  Engine Google APIs OAuth Facebook Graph  API

14

Services – Mail App Engine applications can send email

messages Apps can receive emails at various addresses Apps send messages using the Mail service Apps receive messages in the form of HTTP

requests initiated by App Engine and posted to the app

The Mail service Java API supports the JavaMail interface for sending email messages

The development server does not send email messages

Services

Page 15: Google App  Engine Google APIs OAuth Facebook Graph  API

15

Services – URL Fetch App Engine applications can fetch resources

and communicate with other hosts over the internet using HTTP & HTTPS requests

Apps use URL Fetch service to make requests The URL Fetch service uses Google’s network

infrastructure for efficiency and scaling purposes

Apps use java.net.URLConnection and related classes to make connections

Services

Page 16: Google App  Engine Google APIs OAuth Facebook Graph  API

16

Services – Task Queues Applications can perform work outside of a user

request. The application adds tasks to task queues to be

executed later Two types of queues:

Push Queues function within App Engine environment. ○ Configure a queue and add tasks to it. App Engine

handles the rest.Pull Queues allows consumers inside or outside of App

Engine environment to process tasks○ In this case application needs to scale workers based on

processing volume

Services

Page 17: Google App  Engine Google APIs OAuth Facebook Graph  API

17

Services – Google Cloud Storage The Google Cloud Storage offers another

method for your application to store and serve data

Similar to AWS S3 Access via a RESTful API as well as Cloud

Storage Java API for Google App Engine

Services

Page 18: Google App  Engine Google APIs OAuth Facebook Graph  API

18

Services – Memcache Distributed in-memory data cache Speed up common datastore queries If many requests make the same query with the

same parameters, app can cache the results in memcache

Services

Page 19: Google App  Engine Google APIs OAuth Facebook Graph  API

19

Services – Multitenancy Multitenancy refers to a software architecture

whereby one instance of an application serves many client organization

Namespaces API allows you to compartmentalize Google App Engine data

App Engine supports Namespaces in the following APIsDatastoreMemcacheTask Queue

Services

Page 20: Google App  Engine Google APIs OAuth Facebook Graph  API

20

Services – Google Cloud Endpoints Consists of tools, libraries and capabilities to generate endpoints and client

libraries from an App Engine backend to simplify client access to that back end.

Introduced in Feb 2013 with SDK 1.7.5

Services

Page 21: Google App  Engine Google APIs OAuth Facebook Graph  API

21

Services – Others App Identity

Identifying itselfAsserting identity to Google APIs and other systems

Blobstore: Datastore allows blobs of max 1M. For storing larger objects, use Blobstore

Channel: Use to create persistent connection to send messages to Javascript client in real time.

Images: Manipulate image data using dedicated image service

Logs: Provides access to request and application logs OAuth: Use App Engine application as OAuth service

provider Capabilities, Search, Prospective Search & XMPP (IM)

Services

Page 22: Google App  Engine Google APIs OAuth Facebook Graph  API

22

Google APIs & OAuth Google provides access to many of its services via APIs You can use these APIs within your applications Most of the APIs require authenticated access; OAuth

provides the authentication mechanism OAuth also provides a mechanism to gain access to

private data via scoped authorization Steps to use Google API:

Define a project on Google API consoleSelect the required servicesCreate OAuth client id ( & secret)Use the OAuth flow to get access tokenSend Access token in request header of the HTTP call to

Google API

OAuth Playground

Google APIs Console

Page 23: Google App  Engine Google APIs OAuth Facebook Graph  API

23

Google OAuth Flow (for Web Server Applications)

Page 24: Google App  Engine Google APIs OAuth Facebook Graph  API

24

Facebook API Usage Similar access mechanism as Google API Uses OAuth for authorization Steps to use Facebook API:

Define a Facebook App on developers.facebook.com

This gives you App ID & App SecretUse the App ID & App Secret along with required

permissions to get access tokenSend Access token as request parameter in the

HTTP call to Facebook API Facebook Developers

Page 25: Google App  Engine Google APIs OAuth Facebook Graph  API

25

What else do I need? Something to make the UI look better Frameworks for responsive client

Best ones to start withjQueryTwitter Bootstrap

Some MoreMustache TemplatesjQuery Mobile

Page 26: Google App  Engine Google APIs OAuth Facebook Graph  API

26

Demo – Sample Starter Applications Starter Apps which you can use to begin

developing App Engine application using Google APIs or Facebook APIsGoogle API used – Calendar API to get Calendar listFacebook API used – Get logged in user’s profile

How to use?To learn, copy/paste piece by piece into a new App

Engine projectOR

Import whole project and enhance / modify

Page 27: Google App  Engine Google APIs OAuth Facebook Graph  API

27

Let’s PlayEnvironment SetupCreate App Engine

Project & DeployUse Google and/or

Facebook API In Your Project

Page 28: Google App  Engine Google APIs OAuth Facebook Graph  API

28

References Google App Engine Home: https://developers.google.com/appengine/ App Engine Java Home:

https://developers.google.com/appengine/docs/java/overview App Engine Admin Console: https://appengine.google.com/ Google APIs Console: https://code.google.com/apis/console Google OAuth documentation & flow:

https://developers.google.com/accounts/docs/OAuth2 OAuth Playground: https://developers.google.com/oauthplayground/ Facebook Developers:

https://developers.facebook.com Demo Source Code:

Google APIs starter project: http://commondatastorage.googleapis.com/sessionmaterials/AppEngineStartupProject.zip

Google + Facebook APIs starter project: http://commondatastorage.googleapis.com/sessionmaterials/AppEnginePlusFacebookStartupProject.zip