The document discusses exploring Google APIs using Python and JavaScript. It covers an overview of using Google APIs, including accessing APIs through the Google Developers Console and Google API client libraries. It demonstrates accessing Google APIs through Python code examples for both simple and authorized access. The document also provides an overview of Google Apps Script, how it operates in the JavaScript environment, and code demos for accessing Google APIs through Apps Script.
DevEX - reference for building teams, processes, and platforms
Exploring Google APIs with Python & JavaScript and Google Apps Script
1. Confidential & ProprietaryConfidential & Proprietary
Exploring Google APIs
with Python & JavaScript
+Wesley Chun, @wescpy
Developer Advocate
Silicon Valley CodeCamp
Oct 2015: San José, CA
GDG New York City
Nov 2016: New York, NY
Contribute
questions at:
goo.gl/Rq6ABI
I teach
3. Confidential & Proprietary
Outline
● PART I: Overview of using Google APIs
○ Google Developers Console
○ Google APIs Client Library
○ Simple API key access to Google APIs
○ Authorized (OAuth2) access to Google APIs
○ Python code demos
■ Overview of boilerplate Python code (simple & authorized)
■ Demonstrate accessing 1-2 Google APIs
● PART II: Overview of Google Apps Script
○ Operating environment
○ Supported services
○ JavaScript code demos
■ Demonstrate accessing 1-2 Google APIs
● Summary
(Materials derived from Launchpad Online video series [goo.gl/kFMUa6] content)
Confidential & Proprietary
Google APIs (Part I) & Google Apps Script (Part II)
4. PyCon
May 2016: Portland, OR
BayPIGgies
Aug 2016: Mountain View, CA
Exploring Google APIs
with Python
+Wesley Chun, @wescpy
Developer Advocate
Can't wait? pip{,3} install -U google-api-python-client
AND console.developers.google.com
SF Python project night
Oct 2016: San Francisco, CA
GDG NYC
Nov 2016: New York, NY
Contribute
questions at:
goo.gl/Rq6ABI
Outline
● Overview
● Getting started
● Python
● Live demo(?)
● Wrap-up
18. General OAuth2 process
● Goal: valid access token == 3rd-party API data access
● How OAuth2 works (in general)
○ Step 1: Create OAuth2 credentials in DevConsole
○ Step 2: Send credentials to get access & refresh tokens
○ Step 3: Use access token to make authorized API calls
○ Step 4: Access tokens expire; use refresh to get new one
● developers.google.com/identity/protocols/OAuth2
● Others will be similar (with slight differences)
Authorized API access
21. Listing your files in Google Drive
Use of multiple APIs supported
Simple, authorized, or a mix of both types of APIs; re-uses HTTP client; also see goo.gl/cdm3kZ
22. Write your own or see
github.com/googledrive/zipextractor (JS)
Build a Node.js customized reporting tool with our
Sheets API codelab at g.co/codelabs/sheets (JS)
23. Check out our Node.js Markdown-to-Google Slides
sample app demoing the Slides API
github.com/googlesamples/md2googleslides (JS)
25. Reference
● Google Developers Console
○ console.developers.google.com
● Google APIs Client Library for Python (2 & 3)
○ pip{,3} install -U google-api-python-client
○ developers.google.com/api-client-library/python
■ .../python/guide/{django,google_app_engine} # special
● Other languages
○ developers.google.com/discovery/libraries
Reference
● Blog + video Resources
○ SETUP & BOILERPLATE
■ goo.gl/RbyTFD (new Google APIs project setup)
■ goo.gl/KMfbeK (common Python boilerplate code review)
○ GOOGLE APIs
■ goo.gl/ZIgf8k and goo.gl/EySSQV (Google Drive API)
■ goo.gl/pFYUQ2 (Gmail API)
■ goo.gl/KuYMiq (Google Calendar API)
■ goo.gl/N1RPwC and goo.gl/U6Oljn (Google Sheets API)
■ goo.gl/o6EFwk (Google Slides API)
26. Alternative 1
● Google Apps Script
○ What is it?
■ Executes as JavaScript in Google's cloud
■ Think “built-in” services vs. traditional API usage
■ Convenient access to G Suite/Google Apps data
■ Can also access other Google+external services
■ developers.google.com/apps-script
○ Video resources
■ goo.gl/1sXeuD (Apps Script intro)
■ goo.gl/oAzBN9 (Google Maps & Gmail APIs)
■ goo.gl/YuwZ0E (YouTube [Data] API)
■ goo.gl/xSzGl4 (Google Forms)
Alternative 2
● What about my favorite HTTP request library?
○ requests
■ python-requests.org
○ So can I use 'requests' to talk to Google APIs?
○ Answer: YES, but...
■ Not many examples out there
■ I found one at gist.github.com/ymotongpoo/1907281
■ BUT look at it, ~80% of code is auth{entic,oriz}ation
■ Client Library hides most of it from you
■ Summary: yes you can, but it'll be a DIY effort
27. Alternatives for other Google APIs
● Most, not all, Google APIs work with standard Client Library
● Other APIs/platforms have their own
○ Google AdWords
■ developers.google.com/adwords/api/docs/clientlibraries
○ Google Maps (Web Services)
■ developers.google.com/maps/web-services/client-library
○ Google Cloud Platform
■ cloud.google.com/python/apis
○ Firebase platform (Android, iOS, Web, C++, Node.js, Java)
■ firebase.google.com/docs/libraries
Thank you! Questions?
+Wesley Chun
google.com/+WesleyChun
@wescpy
twitter.com/wescpy
28. Google Apps Script
Accessing G Suite & other Google
services with JavaScript
+Wesley Chun, @wescpy
Developer Advocate
Silicon Valley CodeCamp
Oct 2015: San José, CA
GDG New York City
Nov 2016: New York, NY
Contribute
questions at:
goo.gl/Rq6ABI
Outline
● Background
● What Apps Script is/is NOT
● Supported services
● Use cases
● Example API usage
● Live demo(?)
● Wrap-up
33. Other Google services
But wait, there’s more...
Google Apps services
Admin SDK
Calendar
Contacts
Docs
Drive
Forms
Gmail
Google+ Domains
Groups
Maps
Sites
Sheets
Tasks
Other Google services
AdSense
Analytics
BigQuery
Fusion Tables
goo.gl
Mirror (Glass)
Prediction
Translate
YouTube
Other services
URL Fetch
JDBC
… and more…
42. Confidential & Proprietary
Summary
● We’ve created great technology but can’t build everything(!)
● APIs: our tech available for your apps to integrate with; free?!?
● Access using favorite dev tool via Google APIs Client Library
○ Python, JavaScript (client + Node.js), Java, C#/.NET, Go, Dart, Ruby, PHP
○ Also mobile samples in docs: Android (Java), iOS (Swift, Objective-C)
● Alternative: Google Apps Script
○ More like “built-in” services vs. traditional API usage (above)
○ Convenient access to G Suite/Apps data & other Google+external services
● Build the next great thing!
Confidential & Proprietary
Thank you! Questions?
+Wesley Chun
google.com/+WesleyChun
@wescpy
twitter.com/wescpy
slide deck
goo.gl/TGCm8q