Snapshot before moving away from googleapis

This commit is contained in:
Mahesh Asolkar 2020-04-04 17:57:39 -07:00
parent 07bdc595cd
commit 3882b4e87d
5 changed files with 197 additions and 4 deletions

178
README.md
View File

@ -45,3 +45,181 @@
``` ```
% docker rm d511b20c73d6 % docker rm d511b20c73d6
``` ```
# BUMMER!
* [Google API client for Node.js](https://github.com/googleapis/google-api-nodejs-client) supports the following
APIs, but not Google Photos **!?#@**. Until [these](https://github.com/googleapis/google-api-nodejs-client/issues/1695)
[bugs](https://issuetracker.google.com/issues/138224490) are fixed, will need to use base OAuth2 to access the API.
{
abusiveexperiencereport: [ 'v1' ],
acceleratedmobilepageurl: [ 'v1' ],
accessapproval: [ 'v1', 'v1beta1' ],
accesscontextmanager: [ 'v1', 'v1beta' ],
adexchangebuyer: [ 'v1.2', 'v1.3', 'v1.4' ],
adexchangebuyer2: [ 'v2beta1' ],
adexperiencereport: [ 'v1' ],
admin: [ 'datatransfer_v1', 'directory_v1', 'reports_v1' ],
admob: [ 'v1' ],
adsense: [ 'v1.4' ],
adsensehost: [ 'v4.1' ],
alertcenter: [ 'v1beta1' ],
analytics: [ 'v3' ],
analyticsreporting: [ 'v4' ],
androiddeviceprovisioning: [ 'v1' ],
androidenterprise: [ 'v1' ],
androidmanagement: [ 'v1' ],
androidpublisher: [ 'v1.1', 'v1', 'v2', 'v3' ],
appengine: [ 'v1', 'v1alpha', 'v1beta' ],
appsactivity: [ 'v1' ],
bigquery: [ 'v2' ],
bigqueryconnection: [ 'v1beta1' ],
bigquerydatatransfer: [ 'v1' ],
bigqueryreservation: [ 'v1', 'v1alpha2', 'v1beta1' ],
bigtableadmin: [ 'v1', 'v2' ],
billingbudgets: [ 'v1beta1' ],
binaryauthorization: [ 'v1', 'v1beta1' ],
blogger: [ 'v2', 'v3' ],
books: [ 'v1' ],
calendar: [ 'v3' ],
chat: [ 'v1' ],
civicinfo: [ 'v2' ],
classroom: [ 'v1' ],
cloudasset: [ 'v1', 'v1beta1' ],
cloudbilling: [ 'v1' ],
cloudbuild: [ 'v1', 'v1alpha1', 'v1alpha2' ],
clouddebugger: [ 'v2' ],
clouderrorreporting: [ 'v1beta1' ],
cloudfunctions: [ 'v1', 'v1beta2' ],
cloudidentity: [ 'v1', 'v1beta1' ],
cloudiot: [ 'v1' ],
cloudkms: [ 'v1' ],
cloudprivatecatalog: [ 'v1beta1' ],
cloudprivatecatalogproducer: [ 'v1beta1' ],
cloudprofiler: [ 'v2' ],
cloudresourcemanager: [ 'v1', 'v1beta1', 'v2', 'v2beta1' ],
cloudscheduler: [ 'v1', 'v1beta1' ],
cloudsearch: [ 'v1' ],
cloudshell: [ 'v1', 'v1alpha1' ],
cloudtasks: [ 'v2', 'v2beta2', 'v2beta3' ],
cloudtrace: [ 'v1', 'v2', 'v2beta1' ],
commentanalyzer: [ 'v1alpha1' ],
composer: [ 'v1', 'v1beta1' ],
compute: [ 'alpha', 'beta', 'v1' ],
container: [ 'v1', 'v1beta1' ],
containeranalysis: [ 'v1alpha1', 'v1beta1' ],
content: [ 'v2.1', 'v2' ],
customsearch: [ 'v1' ],
datacatalog: [ 'v1beta1' ],
dataflow: [ 'v1b3' ],
datafusion: [ 'v1beta1' ],
dataproc: [ 'v1', 'v1beta2' ],
datastore: [ 'v1', 'v1beta1', 'v1beta3' ],
deploymentmanager: [ 'alpha', 'v2', 'v2beta' ],
dfareporting: [ 'v3.3', 'v3.4' ],
dialogflow: [ 'v2', 'v2beta1' ],
digitalassetlinks: [ 'v1' ],
discovery: [ 'v1' ],
displayvideo: [ 'v1' ],
dlp: [ 'v2' ],
dns: [ 'v1', 'v1beta2', 'v2beta1' ],
docs: [ 'v1' ],
domainsrdap: [ 'v1' ],
doubleclickbidmanager: [ 'v1.1', 'v1' ],
doubleclicksearch: [ 'v2' ],
drive: [ 'v2', 'v3' ],
driveactivity: [ 'v2' ],
factchecktools: [ 'v1alpha1' ],
fcm: [ 'v1' ],
file: [ 'v1', 'v1beta1' ],
firebase: [ 'v1beta1' ],
firebasedynamiclinks: [ 'v1' ],
firebasehosting: [ 'v1beta1' ],
firebaserules: [ 'v1' ],
firestore: [ 'v1', 'v1beta1', 'v1beta2' ],
fitness: [ 'v1' ],
games: [ 'v1' ],
gamesConfiguration: [ 'v1configuration' ],
gamesManagement: [ 'v1management' ],
genomics: [ 'v1', 'v1alpha2', 'v2alpha1' ],
gmail: [ 'v1' ],
groupsmigration: [ 'v1' ],
groupssettings: [ 'v1' ],
healthcare: [ 'v1beta1' ],
homegraph: [ 'v1' ],
iam: [ 'v1' ],
iamcredentials: [ 'v1' ],
iap: [ 'v1', 'v1beta1' ],
identitytoolkit: [ 'v3' ],
indexing: [ 'v3' ],
jobs: [ 'v2', 'v3', 'v3p1beta1' ],
kgsearch: [ 'v1' ],
language: [ 'v1', 'v1beta1', 'v1beta2' ],
libraryagent: [ 'v1' ],
licensing: [ 'v1' ],
lifesciences: [ 'v2beta' ],
logging: [ 'v2' ],
managedidentities: [ 'v1', 'v1alpha1', 'v1beta1' ],
manufacturers: [ 'v1' ],
mirror: [ 'v1' ],
ml: [ 'v1' ],
monitoring: [ 'v1', 'v3' ],
networkmanagement: [ 'v1beta1' ],
oauth2: [ 'v1', 'v2' ],
osconfig: [ 'v1beta' ],
oslogin: [ 'v1', 'v1alpha', 'v1beta' ],
pagespeedonline: [ 'v1', 'v2', 'v4', 'v5' ],
people: [ 'v1' ],
playcustomapp: [ 'v1' ],
plus: [ 'v1' ],
policytroubleshooter: [ 'v1', 'v1beta' ],
poly: [ 'v1' ],
prod_tt_sasportal: [ 'v1alpha1' ],
proximitybeacon: [ 'v1beta1' ],
pubsub: [ 'v1', 'v1beta1a', 'v1beta2' ],
recommender: [ 'v1beta1' ],
redis: [ 'v1', 'v1beta1' ],
remotebuildexecution: [ 'v1', 'v1alpha', 'v2' ],
reseller: [ 'v1' ],
run: [ 'v1', 'v1alpha1', 'v1beta1' ],
runtimeconfig: [ 'v1', 'v1beta1' ],
safebrowsing: [ 'v4' ],
sasportal: [ 'v1alpha1' ],
script: [ 'v1' ],
searchconsole: [ 'v1' ],
secretmanager: [ 'v1', 'v1beta1' ],
securitycenter: [ 'v1', 'v1beta1', 'v1p1alpha1', 'v1p1beta1' ],
serviceconsumermanagement: [ 'v1' ],
servicecontrol: [ 'v1' ],
servicemanagement: [ 'v1' ],
servicenetworking: [ 'v1', 'v1beta' ],
serviceusage: [ 'v1', 'v1beta1' ],
sheets: [ 'v4' ],
siteVerification: [ 'v1' ],
slides: [ 'v1' ],
sourcerepo: [ 'v1' ],
spanner: [ 'v1' ],
speech: [ 'v1', 'v1p1beta1', 'v2beta1' ],
sql: [ 'v1beta4' ],
storage: [ 'v1', 'v1beta2' ],
storagetransfer: [ 'v1' ],
streetviewpublish: [ 'v1' ],
tagmanager: [ 'v1', 'v2' ],
tasks: [ 'v1' ],
testing: [ 'v1' ],
texttospeech: [ 'v1', 'v1beta1' ],
toolresults: [ 'v1beta3' ],
tpu: [ 'v1', 'v1alpha1' ],
translate: [ 'v2', 'v3', 'v3beta1' ],
vault: [ 'v1' ],
verifiedaccess: [ 'v1' ],
videointelligence: [ 'v1', 'v1beta2', 'v1p1beta1', 'v1p2beta1', 'v1p3beta1' ],
vision: [ 'v1', 'v1p1beta1', 'v1p2beta1' ],
webfonts: [ 'v1' ],
webmasters: [ 'v3' ],
websecurityscanner: [ 'v1', 'v1alpha', 'v1beta' ],
youtube: [ 'v3' ],
youtubeAnalytics: [ 'v1', 'v2' ],
youtubereporting: [ 'v1' ]
}

View File

@ -67,7 +67,12 @@ function authorize(credentials, req, res, callback) {
fs.readFile(TOKEN_PATH, (err, token) => { fs.readFile(TOKEN_PATH, (err, token) => {
if (err) return getAccessToken(oAuth2Client, req, res, callback); if (err) return getAccessToken(oAuth2Client, req, res, callback);
oAuth2Client.setCredentials(JSON.parse(token)); oAuth2Client.setCredentials(JSON.parse(token));
callback(req, res); var apis = google.getSupportedAPIs();
console.log(apis);
// TODO: Need to wait until googleapis supports Google Photos.
// Will revisit this at that point
var api = google;
callback(req, res, api);
}); });
} }

View File

@ -20,6 +20,7 @@ app.get('/redirect', (req, res) => auth.redirect(req, res));
// - Authenticated routes // - Authenticated routes
app.get('/tiny', (req, res) => auth.run(req, res, tasks.tiny_photos)); app.get('/tiny', (req, res) => auth.run(req, res, tasks.tiny_photos));
app.get('/albums', (req, res) => auth.run(req, res, tasks.albums));
// - Assets // - Assets
app.get('/favicon.ico', (req, res) => res.sendStatus(204)); app.get('/favicon.ico', (req, res) => res.sendStatus(204));

View File

@ -45,7 +45,7 @@ function page_head(title) {
</head> </head>
<body> <body>
<h1 class="title">${config.app_name}</h1> <h1 class="title">${config.app_name}</h1>
<p class="content"><a href="/">Home</a> | <a href="/tiny">Tiny Photos</a></p>`; <p class="content"><a href="/">Home</a> | <a href="/albums">Albums</a> | <a href="/tiny">Tiny Photos</a></p>`;
} }
function page_tail() { function page_tail() {

View File

@ -23,7 +23,7 @@ function home_page(req, res) {
res.send(pg); res.send(pg);
} }
function tiny_photos(req, res) { function tiny_photos(req, res, api) {
var pg = page.head("Tiny photos"); var pg = page.head("Tiny photos");
pg += `<p class="content">These are the tiny photos in your library</p>`; pg += `<p class="content">These are the tiny photos in your library</p>`;
pg += page.tail(); pg += page.tail();
@ -31,11 +31,20 @@ function tiny_photos(req, res) {
res.send(pg); res.send(pg);
} }
function albums(req, res, api) {
var pg = page.head("Albums");
pg += `<p class="content">These are the albums in your library</p>`;
pg += page.tail();
res.send(pg);
}
// Exported functions // Exported functions
module.exports = { module.exports = {
not_found: not_found, not_found: not_found,
home_page: home_page, home_page: home_page,
tiny_photos: tiny_photos tiny_photos: tiny_photos,
albums: albums
} }
// vim: ai ts=4 sts=4 et sw=4 ft=javascript // vim: ai ts=4 sts=4 et sw=4 ft=javascript