Giter Club home page Giter Club logo

google-photos's Introduction

Google Photos Library API Samples

This repository contains a sample for the Google Photos Library API.

The Library API lets you read, write and share photos & videos in Google Photos.

Samples

The REST/Photoframe sample shows how to use the REST API in a Node.JS web application to build an interactive photo frame that loads photos from a user's Google Photos library. It is built with express.js.

Running the samples

Follow the README for the REST/Photoframe sample for steps on how to get started.

Support

If you've found an error in this sample, please file an issue: https://github.com/googlesamples/google-photos

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.

License

Copyright 2018 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

google-photos's People

Contributors

chrisachard avatar jfschmakeit avatar schizoduckie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-photos's Issues

Quota

Are the uploaded media counts against the Google drive quota?

Requires Google+ API

When I ran the sample I got this error:

GooglePlusAPIError: Access Not Configured. Google+ API has not been used in project XXXX before or it is disabled. 
Enable it by visiting https://console.developers.google.com/apis/api/plus.googleapis.com/overview?project=XXXX then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
    at /XXX/REST/PhotoFrame/node_modules/passport-google-oauth20/lib/strategy.js:95:21
   ...

This should be mentioned in the readme setup instructions, or perhaps given the dependency should be removed.

Error: req#logout requires a callback function

Error

Error: req#logout requires a callback function
    at req.logout.req.logOut (/home/freephoenix888/Programming/google-photos/REST/PhotoFrame/node_modules/passport/lib/http/request.js:65:44)
    at file:///home/freephoenix888/Programming/google-photos/REST/PhotoFrame/app.js:204:7
    at Layer.handle [as handle_request] (/home/freephoenix888/Programming/google-photos/REST/PhotoFrame/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/freephoenix888/Programming/google-photos/REST/PhotoFrame/node_modules/express/lib/router/route.js:144:13)
    at Route.dispatch (/home/freephoenix888/Programming/google-photos/REST/PhotoFrame/node_modules/express/lib/router/route.js:114:3)
    at Layer.handle [as handle_request] (/home/freephoenix888/Programming/google-photos/REST/PhotoFrame/node_modules/express/lib/router/layer.js:95:5)
    at /home/freephoenix888/Programming/google-photos/REST/PhotoFrame/node_modules/express/lib/router/index.js:284:15
    at Function.process_params (/home/freephoenix888/Programming/google-photos/REST/PhotoFrame/node_modules/express/lib/router/index.js:346:12)
    at next (/home/freephoenix888/Programming/google-photos/REST/PhotoFrame/node_modules/express/lib/router/index.js:280:10)
    at file:///home/freephoenix888/Programming/google-photos/REST/PhotoFrame/app.js:185:3

How to reproduce

  1. Do everything described here: https://github.com/googlesamples/google-photos/tree/main/REST/PhotoFrame#set-up
  2. Login
  3. Click "Disconnect" to logout
  4. See error

Does it support image uploads? (REST API)

The document has an upload function.

It does not exist in the sample.

I want to know if the image upload function is a stable function.

Where is the article on response types for image upload failures?

This sample not compatible with the latest version of node.js v10.23.0

Dear Google developer community.
I have a humble request. I am trying to run this sample application under the latest version of Node.js. However I keep running into several compiler issues in app.js. For example I had to change the following lines to move forward

//import bodyParser from 'body-parser';
var bodyParser = require ('body-parser');

Now I am stuck at this line in app.js.
const dirname = path.dirname(new URL(import.meta.url).pathname);
^^^^
SyntaxError: Cannot use 'import.meta' outside a module

Would someone please help me in the migration of this great sample app to the latest version of node.js? I am not Node.js expert. I am sure someone with node.js expertise has already migrated it to the latest version of node.js. Would you kindly share it here for people like me?

Thanks in advance
-Arun

InternalOAuthError: Failed to obtain access token

Hi
I can't get through Sign in with Google

My credentials:

{
    "web": {
        "client_id": "my client id",
        "project_id": "my project id",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://www.googleapis.com/oauth2/v3/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_secret": "my client secret",
        "redirect_uris": [
            "http://127.0.0.1:8080/auth/google/callback"
        ],
        "javascript_origins": [
            "http://127.0.0.1"
        ]
    }
}

I got InternalOAuthError: Failed to obtain access token

InternalOAuthError: Failed to obtain access token
    at Strategy.OAuth2Strategy._createOAuthError (/Users/isan/Downloads/google-photos-master/REST/PhotoFrame/node_modules/passport-oauth2/lib/strategy.js:379:17)
    at /Users/isan/Downloads/google-photos-master/REST/PhotoFrame/node_modules/passport-oauth2/lib/strategy.js:166:45
    at /Users/isan/Downloads/google-photos-master/REST/PhotoFrame/node_modules/oauth/lib/oauth2.js:191:18
    at ClientRequest.<anonymous> (/Users/isan/Downloads/google-photos-master/REST/PhotoFrame/node_modules/oauth/lib/oauth2.js:162:5)
    at ClientRequest.emit (events.js:182:13)
    at TLSSocket.socketErrorListener (_http_client.js:382:9)
    at TLSSocket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Accessing hdr photo

Hey everyone,

I would like to display the hdr and ultra hdr photos stored on a Google photos account. Looking at the mediaitem info, I don't see anyway to access this info.

How can I go about calling the API and displaying hdr images?

Thank you

dirname doesn't work on windows

On windows with Node v16.13.1, in app.js, line 35:
const dirname = path.dirname(new URL(import.meta.url).pathname);
yields: '/C:/your-project...' and all associated mappings 404.

I changed line 35 to:
const dirname = path.resolve();
which correctly yields: 'C:/your-project...' - drops leading '/'
This works on windows.

Broken images in gallery

The "Photo frame preview" shows many broken images:

screen shot 2018-05-09 at 8 08 18 am

Clicking on one of the broken image links shows an error "The requested content cannot be loaded":

screen shot 2018-05-09 at 8 08 31 am

Clicking on the "Click to open in Google Photos" link at the bottom does open the photo on photos.google.com, as expected.

All of these photos were uploaded fairly recently (in the last 15 minutes?) if that makes any difference.

add node.js minimum version to documentation

It would be nice if the minimum version for nodejs would be specified.

And problems even starting the app because my nodejs version wasn't really updated and it kept complaining about the async functions which were only introduced in node v7.6

Expired baseUrl

Hi there, I really like your photo-frame-sample application, but I'm having the following issue, hoping you can help:

When running a slide show on a large album, the baseUrl to the image expires after 60 seconds. My custom built photo frame running the photo-frame-sample app then displays an error when fancybox tries to load the next image of the slide show. Can you think of a fix that would allow running the slideshow for durations >60 minutes?

Somehow the link that wraps the image needs to point to a ressource that retrieves a valid baseUrl during runtime of the slideshow. Could we call mediaItems.get using the mediaItemId to dynamically obtain a vailid baseUrl when fancybox tries to access an image?

Regards

install

tryed to install the script going through the readme.
My first issue is with the line: "Set the authorized JavaScript origin to ..." - where?
Having left this, but everything else - I get an error when running "node app.js"
a) express-session deprecated undefined resave option
b) express-session deprecated undefined saveUninitialized option
.....

Any advice for me? Thanks

mediaType:['PHOTO'] is not working

When I use this filter in mediaItems:search

filters = {
      mediaTypeFilter: {
        mediaTypes: ["PHOTO"] 
      }
};

I meet this error.

{ error:
   { code: 400,
     message: 'Invalid JSON payload received. Unknown name "filters[mediaTypeFilter][mediaTypes][0]": Cannot bind query parameter. Field \'filters[mediaTypeFilter][mediaTypes][0]\' could not be found in request message.',
     status: 'INVALID_ARGUMENT',
     details: [ [Object] ] } }

But, when I use this,

filters = {
      mediaTypeFilter: {
        mediaTypes: [] 
      }
};

There is no error. All media are returned.

I want to get only photos, but I cannot figure out what is wrong.

Deploy in heroku fails

I edited the package.json as follows and tried to deploy to heroku NPM. Could you please help?

  1. Fails also without DEBUG=TRUE
  2. Build succeeds but deploy fails
  3. I put appropriate values for clientID and secret in config.js, URL.
REST/PhotoFrame/config.js 
config.oAuthClientID  config.oAuthclientSecret 
config.oAuthCallbackUrl = 'https://REDACTED.herokuapp.com/auth/google/callback';
 The port where the app should listen for requests.
config.port = 443;

The file:

cat  package.json 
{
  "name": "photo-frame-sample",
  "version": "1.0.0",
  "description": "Google Photos Library API photo frame sample",
  "private": true,
  "license": "Apache-2.0",
  "author": "Google LLC",
  "repository": {
    "type": "git",
    "url": "https://github.com/googlesamples/google-photos.git"
  },
  "main": "app.js",
  "type": "module",
  "dependencies": {
    "@fancyapps/fancybox": "^3.5.7",
    "body-parser": "^1.19.1",
    "ejs": "^3.1.6",
    "express": "^4.17.2",
    "express-session": "^1.17.2",
    "express-winston": "^4.2.0",
    "jquery": "^3.6.0",
    "material-design-icons": "^3.0.1",
    "material-design-lite": "^1.3.0",
    "node-fetch": "^3.1.0",
    "node-persist": "^3.1.0",
    "passport": "^0.5.2",
    "passport-google-oauth20": "^2.0.0",
    "session-file-store": "^1.5.0",
    "winston": "^3.3.3"
  },
  "scripts": {
    "start": "DEBUG=TRUE node REST/PhotoFrame/app.js"
  },
  "engines": {
    "node": "14.x"
  }
}
 heroku[web.1]: State changed from crashed to starting
 app[api]: Build succeeded
 heroku[web.1]: Starting process with command `npm start`
 app[web.1]: 
 app[web.1]: > [email protected] start /app
 app[web.1]: > DEBUG=TRUE node REST/PhotoFrame/app.js
 app[web.1]: 
 app[web.1]: events.js:377
 app[web.1]: throw er; // Unhandled 'error' event
 app[web.1]: ^
 app[web.1]: 
 app[web.1]: Error: listen EACCES: permission denied 0.0.0.0:443
 app[web.1]: at Server.setupListenHandle [as _listen2] (net.js:1314:21)
 app[web.1]: at listenInCluster (net.js:1379:12)
 app[web.1]: at Server.listen (net.js:1465:7)
 app[web.1]: at file:///app/REST/PhotoFrame/app.js:398:8
 app[web.1]: at ModuleJob.run (internal/modules/esm/module_job.js:183:25)
 app[web.1]: at async Loader.import (internal/modules/esm/loader.js:178:24)
 app[web.1]: at async Object.loadESM (internal/process/esm_loader.js:68:5)
 app[web.1]: at async handleMainPromise (internal/modules/run_main.js:59:12)
 app[web.1]: Emitted 'error' event on Server instance at:
 app[web.1]: at emitErrorNT (net.js:1358:8)
 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:82:21) {
 app[web.1]: code: 'EACCES',
 app[web.1]: errno: -13,
 app[web.1]: syscall: 'listen',
 app[web.1]: address: '0.0.0.0',
 app[web.1]: port: 443
 app[web.1]: }
 app[web.1]: npm ERR! code ELIFECYCLE
 app[web.1]: npm ERR! errno 1
 app[web.1]: npm ERR! [email protected] start: `DEBUG=TRUE node REST/PhotoFrame/app.js`
 app[web.1]: npm ERR! Exit status 1
 app[web.1]: npm ERR!
 app[web.1]: npm ERR! Failed at the [email protected] start script.
 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
 app[web.1]: 
 app[web.1]: npm ERR! A complete log of this run can be found in:
 app[web.1]: npm ERR!     /app/.npm/_logs/2022-05-01T16_39_40_608Z-debug.log
 heroku[web.1]: Process exited with status 1
 heroku[web.1]: State changed from starting to crashed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.