Skip to content

wescpy/gsuite-apis-intro

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Workspace ("GWS") APIs intro codelab

This codelab introduces developers to Google Workspace (formerly G Suite) APIs (Gmail, Google Drive, Calendar, Sheets, Slides, etc.) by writing a simple Python script that lists the first 100 files/folders in a user's Google Drive. Access it at http://g.co/codelabs/gsuite-apis-intro. While that tutorial and the majority of this README focuses on Python, this repo contains code samples for both Python (2 and 3) and Node.js.

Prerequisites

  • A Google account (Google Workspace accounts may require administrator approval)
  • Familiarity with shell commands on POSIX-compliant systems (Linux, Mac OS X); Windows users also welcome
  • Ability to create source files with either a code editor or shell commands.
  • Basic skills in Python (2 or 3) or Node.js
  • Some files and/or folders in your Google Drive

Description

This repo is part of the codelab introducing developers to using Google Workspace ("GWS") RESTful HTTP APIs. The code examples are in Python and Node.js for brevity and wide availability, but all common languages are supported. The tutorial shows how to use the developer console to create and manage projects, including obtaining the credentials needed in your apps, then moves on to the primary code sample that displays the first 100 files & folders in your Google Drive by using the Drive API.

oauth2client library deprecated

The oauth2client library was deprecated in 2017 in favor of newer replacements. However the newer libraries do not yet support either user authorization nor user credentials storage, two features that are required in this codelab. When those features become available, we will migrate to the newer libraries. For now, oauth2client still works, even in maintenance mode, and provides automated, threadsafe, and 2.x/3.x-compatible storage of and access to OAuth2 tokens for users whereas the newer libraries do not (yet).

Cost

Use of the Google Drive API (and most GWS APIs) are covered by a monthly subscription fee, including the free consumer Google/Gmail accounts (monthly fee of $0USD), meaning you can use the APIs as long as you stay within each API's daily/monthly limits. Exceeding the limits will result in failed requests/exceptions. Not all of the quotas are published, but some general quotas for all GWS APIs can be found on the Google Services quotas page. Some APIs have a support page where developers can request additional quota.

Source files

Filename Description
python/drive_list.py The original sample app as featured in codelab (uses older, deprecated auth libraries but matches much of the code that's still online)
python/drive_list-new.py Same as drive_list.py but uses newer (current) auth libraries (must manage auth tokens [see extra JSON storage code])
nodejs/drive_list.js The Node.js/JavaScript version of the script (also have to manage auth token storage)
nodejs/drive_list.mjs Same as drive_list.js but with ES module imports instead of requires.

Resources

If you've found an error in the codelab or the sample app, check the Issues tab to see if there's an open issue or file a new one. Patches are encouraged; please refer to CONTRIBUTING for details.