hermanho / MMM-GooglePhotos

Display your photos on MagicMirror from Google Photos.
MIT License
170 stars 65 forks source link

No photos are displayed #116

Closed ericgeezzle closed 3 years ago

ericgeezzle commented 3 years ago

HI, great work making this available and helping out with issues so well. i am extremely green, so please bear with me and really break it down. I am trying to get the MM to work with google photos to no avail. the program launches then blank screen, only news feed and time and date, i disabled other modules except photos and the other two. I have tried reinstall and changing token no luck. This is the error i get below... please help.

[INFO]  Checking git for module: MMM-GooglePhotos
[15.09.2021 23:33.24.961] [ERROR] (node:1641) UnhandledPromiseRejectionWarning: Error: Request failed with status code 
403
at createError (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/pi/MagicMirror/modules/MMM- 
GooglePhotos/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
[15.09.2021 23:33.24.963] [ERROR] (node:1641) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This 
error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not 
handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled- 
rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
[15.09.2021 23:33.24.963] [ERROR] (node:1641) [DEP0018] DeprecationWarning: Unhandled promise rejections are 
deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[15.09.2021 23:33.25.739] [INFO]  Newsfeed-Fetcher: Broadcasting 51 items.
[15.09.2021 23:34.19.813] [ERROR] (node:1641) UnhandledPromiseRejectionWarning: Error: Request failed with status code 
403
at createError (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/pi/MagicMirror/modules/MMM- 
GooglePhotos/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
[15.09.2021 23:34.19.815] [ERROR] (node:1641) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This 
error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not 
handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled- 
rejections=strict` 
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
aneaville commented 3 years ago

I'll admit that there is a lot of stuff not helpful in this log. The thing to focus on is the "Error: Request failed with status code 403" which means you don't have access to your google photos. There is several possible reasons for this. Search the previous issues for '403' and look especially at issues 109 and 106.

If neither of those helps, were you able to successfully get the token?

ericgeezzle commented 3 years ago

Thank you for the reply... The token.json is in the MMM-Google Photos directory. The photos library API is also enabled pic below. Permission granted too, for scope i even selected everything related to photos. I created an album with 5 photos i want to put up. For the config part of the photos module under album i have put in the album name, the album share link, no luck with either. Not sure what to put there, i think that might be the issue as i think it points to what album to open. This is what the config file looks like

let config = {
    address: "localhost",   // Address to listen on, can be:
                        // - "localhost", "127.0.0.1", "::1" to listen on loopback interface
                        // - another specific IPv4/6 to listen on a specific interface
                        // - "0.0.0.0", "::" to listen on any interface
                        // Default, when address config is left out or empty, is "localhost"
    port: 8080,
    basePath: "/",  // The URL path where MagicMirror is hosted. If you are using a Reverse proxy
                    // you mulet config = {
    address: "localhost",   // Address to listen on, can be:
                        // - "localhost", "127.0.0.1", "::1" to listen on loopback interface
                        // - another specific IPv4/6 to listen on a specific interface
                        // - "0.0.0.0", "::" to listen on any interface
                        // Default, when address config is left out or empty, is "localhost"
    port: 8080,
    basePath: "/",  // The URL path where MagicMirror is hosted. If you are using a Reverse proxy
                // you must set the sub path here. basePath must end with a /
    ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],  // Set [] to allow all IP addresses
                                                        // or add a specific IPv4 of 192.168.1.5 :
                                                        // ["127.0.0.1", "::ffff:127.0.0.1", "::1", 
"::ffff:192.168.1.5"],
                                                        // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use 
CIDR format :
                                                        // ["127.0.0.1", "::ffff:127.0.0.1", "::1", 
"::ffff:192.168.3.0/28"],

useHttps: false,        // Support HTTPS or not, default "false" will use HTTP
httpsPrivateKey: "",    // HTTPS private key path, only require when useHttps is true
httpsCertificate: "",   // HTTPS Certificate path, only require when useHttps is true

language: "en",
locale: "en-US",
logLevel: ["INFO", "LOG", "WARN", "ERROR", "DEBUG"], // Add "DEBUG" for even more logging
timeFormat: 24,
units: "metric",
debug: true,
// serverOnly:  true/false/"local" ,
// local for armv6l processors, default
//   starts serveronly and then starts chrome browser
// false, default for all NON-armv6l devices
// true, force serveronly mode, because you want to.. no UI on this device

modules: [
    {
        module: "alert",
    },
    {
        module: "updatenotification",
        position: "top_bar"
    },
    {
        module: "clock",
        position: "top_left"
    },
    {
        module: "MMM-GooglePhotos",
        position: "middle_center",
        config: {
                albums: "https://photos.app.goo.gl/sv2DKUcpzaxD5tAN8", // Set your album name. like ["My wedding", 
"family share", "Travle to Paris"]
                updateInterval: 1000 * 60, // minimum 10 seconds.
                sort: "new", // "old", "random"
                uploadAlbum: null, // Only album created by `create_uploadable_album.js`.
                condition: {
                    fromDate: null, // Or "2018-03", RFC ... format available
                    toDate: null, // Or "2019-12-25",
                    minWidth: null, // Or 400
                    maxWidth: null, // Or 8000
                    minHeight: null, // Or 400
                    maxHeight: null, // Or 8000
                    minWHRatio: null,
                    maxWHRatio: null,
                    // WHRatio = Width/Height ratio ( ==1 : Squared Photo,   < 1 : Portraited Photo, > 1 : Landscaped 
Photo)
                },
                showWidth: 1080, // These values will be used for quality of downloaded photos to show. real size to 
show in your MagicMirror region is recommended.
                showHeight: 1920,
                timeFormat: "YYYY/MM/DD HH:mm", // Or `relative` can be used.
        }
        },

    /*
    {
        module: "calendar",
        header: "US Holidays",
        position: "top_left",
        config: {
            calendars: [
                {
                    symbol: "calendar-check",
                    url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics"                   }
            ]
        }
    },
    {
        module: "compliments",
        position: "lower_third"
    },
    {
        module: "weather",
        position: "top_right",
        config: {
            weatherProvider: "openweathermap",
            type: "current",
            location: "New York",
            locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and 
find your city
            apiKey: "YOUR_OPENWEATHER_API_KEY"
        }
    },
    {
        module: "weather",
        position: "top_right",
        header: "Weather Forecast",
        config: {
            weatherProvider: "openweathermap",
            type: "forecast",
            location: "New York",
            locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and 
find your city
            apiKey: "YOUR_OPENWEATHER_API_KEY"
        }
    },
    */
    {
        module: "newsfeed",
        position: "bottom_bar",
        config: {
            feeds: [
                {
                    title: "New York Times",
                    url: "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml"
                }
            ],
            showSourceTitle: true,
            showPublishDate: true,
            broadcastNewsFeeds: true,
            broadcastNewsUpdates: true
        }
    },
]
};

/ DO NOT EDIT THE LINE BELOW / if (typeof module !== "undefined") {module.exports = config;}st set the sub path here. basePath must end with a / ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], // Set [] to allow all IP addresses // or add a specific IPv4 of 192.168.1.5 : // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"], // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format : // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"],

useHttps: false,        // Support HTTPS or not, default "false" will use HTTP
httpsPrivateKey: "",    // HTTPS private key path, only require when useHttps is true
httpsCertificate: "",   // HTTPS Certificate path, only require when useHttps is true

language: "en",
locale: "en-US",
logLevel: ["INFO", "LOG", "WARN", "ERROR", "DEBUG"], // Add "DEBUG" for even more logging
timeFormat: 24,
units: "metric",
debug: true,
// serverOnly:  true/false/"local" ,
// local for armv6l processors, default
//   starts serveronly and then starts chrome browser
// false, default for all NON-armv6l devices
// true, force serveronly mode, because you want to.. no UI on this device

modules: [
    {
        module: "alert",
    },
    {
        module: "updatenotification",
        position: "top_bar"
    },
    {
        module: "clock",
        position: "top_left"
    },
    {
        module: "MMM-GooglePhotos",
        position: "middle_center",
        config: {
                albums: "https://photos.app.goo.gl/sv2DKUcpzaxD5tAN8", // Set your album name. like ["My wedding", "family share", "Travle to Paris"]
                updateInterval: 1000 * 60, // minimum 10 seconds.
                sort: "new", // "old", "random"
                uploadAlbum: null, // Only album created by `create_uploadable_album.js`.
                condition: {
                    fromDate: null, // Or "2018-03", RFC ... format available
                    toDate: null, // Or "2019-12-25",
                    minWidth: null, // Or 400
                    maxWidth: null, // Or 8000
                    minHeight: null, // Or 400
                    maxHeight: null, // Or 8000
                    minWHRatio: null,
                    maxWHRatio: null,
                    // WHRatio = Width/Height ratio ( ==1 : Squared Photo,   < 1 : Portraited Photo, > 1 : Landscaped Photo)
                },
                showWidth: 1080, // These values will be used for quality of downloaded photos to show. real size to show in your MagicMirror region is recommended.
                showHeight: 1920,
                timeFormat: "YYYY/MM/DD HH:mm", // Or `relative` can be used.
        }
        },

    /*
    {
        module: "calendar",
        header: "US Holidays",
        position: "top_left",
        config: {
            calendars: [
                {
                    symbol: "calendar-check",
                    url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics"                   }
            ]
        }
    },
    {
        module: "compliments",
        position: "lower_third"
    },
    {
        module: "weather",
        position: "top_right",
        config: {
            weatherProvider: "openweathermap",
            type: "current",
            location: "New York",
            locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
            apiKey: "YOUR_OPENWEATHER_API_KEY"
        }
    },
    {
        module: "weather",
        position: "top_right",
        header: "Weather Forecast",
        config: {
            weatherProvider: "openweathermap",
            type: "forecast",
            location: "New York",
            locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
            apiKey: "YOUR_OPENWEATHER_API_KEY"
        }
    },
    */
    {
        module: "newsfeed",
        position: "bottom_bar",
        config: {
            feeds: [
                {
                    title: "New York Times",
                    url: "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml"
                }
            ],
            showSourceTitle: true,
            showPublishDate: true,
            broadcastNewsFeeds: true,
            broadcastNewsUpdates: true
        }
    },
]

}; 2021-09-17-021606_1920x1080_scrot

2021-09-17-022737_1920x1080_scrot

/ DO NOT EDIT THE LINE BELOW / if (typeof module !== "undefined") {module.exports = config;}

aneaville commented 3 years ago

Thanks for the detailed info.

Looking through your config, one area that stood out is:

albums: "https://photos.app.goo.gl/sv2DKUcpzaxD5tAN8",

typically this would just be the name of your album rather than a link. This might cause your issue. Can you please try changing this to

albums: "album name", //where album name would be something like "family and friends", "vacation", etc.

If that doesn't work, please add debug: true, to your google photos configuration. This will make the logs more verbose. Please share the log after startup.

ericgeezzle commented 3 years ago

The changes have been made... no luck, here is the log. A pic of what the mirror looks like is displayed below. the album i want to use in google photos is titled 'MagicMirror' and has been put in config as advised.

> magicmirror@2.16.0 start /home/pi/MagicMirror
> DISPLAY="${DISPLAY:=:0}" ./node_modules/.bin/electron js/electron.js

[17.09.2021 06:19.19.299] [LOG]   Starting MagicMirror: v2.16.0
[17.09.2021 06:19.19.304] [LOG]   Loading config ...
[17.09.2021 06:19.19.312] [LOG]   Loading module helpers ...
[17.09.2021 06:19.19.315] [LOG]   No helper found for module: alert.
[17.09.2021 06:19.19.580] [LOG]   Initializing new module helper ...
[17.09.2021 06:19.19.581] [LOG]   Module helper loaded: updatenotification
[17.09.2021 06:19.19.583] [LOG]   No helper found for module: clock.
[17.09.2021 06:19.20.065] [LOG]   Initializing new module helper ...
[17.09.2021 06:19.20.066] [LOG]   Module helper loaded: MMM-GooglePhotos
[17.09.2021 06:19.20.112] [LOG]   Initializing new module helper ...
[17.09.2021 06:19.20.112] [LOG]   Module helper loaded: newsfeed
[17.09.2021 06:19.20.113] [LOG]   All module helpers loaded.
[17.09.2021 06:19.20.247] [LOG]   Starting server on port 8080 ... 
[17.09.2021 06:19.20.269] [LOG]   Server started ...
[17.09.2021 06:19.20.270] [LOG]   Connecting socket for: updatenotification
[17.09.2021 06:19.20.271] [LOG]   Connecting socket for: MMM-GooglePhotos
[17.09.2021 06:19.20.272] [LOG]   Connecting socket for: newsfeed
[17.09.2021 06:19.20.272] [LOG]   Starting node helper for: newsfeed
[17.09.2021 06:19.20.273] [LOG]   Sockets connected & modules started ...
[17.09.2021 06:19.20.779] [LOG]   Launching application.
[17.09.2021 06:19.23.044] [LOG]   [GPHOTOS] Starting Initialization
[17.09.2021 06:19.23.047] [LOG]   [GPHOTOS] Getting album list
[17.09.2021 06:19.23.055] [LOG]   Create new newsfetcher for url: 
https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml - Interval: 300000
[17.09.2021 06:19.23.136] [INFO]  Checking git for module: MMM-GooglePhotos
[17.09.2021 06:19.23.142] [LOG]   [GPHOTOS:AUTH] Token is expired.
[17.09.2021 06:19.23.706] [LOG]   [GPHOTOS:AUTH] Token is refreshed.
[17.09.2021 06:19.23.708] [LOG]   [GPHOTOS:CORE] Getting Album info chunks.
[17.09.2021 06:19.29.187] [INFO]  Newsfeed-Fetcher: Broadcasting 52 items.
[17.09.2021 06:19.29.222] [LOG]   [GPHOTOS:CORE] Error: Request failed with status code 403
[17.09.2021 06:19.29.225] [ERROR] (node:943) UnhandledPromiseRejectionWarning: Error: Request failed with status code 
403
at createError (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/pi/MagicMirror/modules/MMM- 
GooglePhotos/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
[17.09.2021 06:19.29.226] [ERROR] (node:943) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This 
error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not 
handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled- 
rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
[17.09.2021 06:19.29.227] [ERROR] (node:943) [DEP0018] DeprecationWarning: Unhandled promise rejections are 
deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[17.09.2021 06:20.23.050] [LOG]   [GPHOTOS] Starting Initialization
[17.09.2021 06:20.23.052] [LOG]   [GPHOTOS] Getting album list
[17.09.2021 06:20.23.056] [LOG]   [GPHOTOS:AUTH] Token is alive.
[17.09.2021 06:20.23.058] [LOG]   [GPHOTOS:CORE] Getting Album info chunks.
[17.09.2021 06:20.24.592] [LOG]   [GPHOTOS:CORE] Error: Request failed with status code 403
[17.09.2021 06:20.24.595] [ERROR] (node:943) UnhandledPromiseRejectionWarning: Error: Request failed with status code 
403
at createError (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/pi/MagicMirror/modules/MMM- 
GooglePhotos/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21 )

2021-09-17-062000_1920x1080_scrot

let config = {
address: "localhost",   // Address to listen on, can be:
                        // - "localhost", "127.0.0.1", "::1" to listen on loopback interface
                        // - another specific IPv4/6 to listen on a specific interface
                        // - "0.0.0.0", "::" to listen on any interface
                        // Default, when address config is left out or empty, is "localhost"
port: 8080,
basePath: "/",  // The URL path where MagicMirror is hosted. If you are using a Reverse proxy
                // you must set the sub path here. basePath must end with a /
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],  // Set [] to allow all IP addresses
                                                        // or add a specific IPv4 of 192.168.1.5 :
                                                        // ["127.0.0.1", "::ffff:127.0.0.1", "::1", 
"::ffff:192.168.1.5"],
                                                        // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use 
CIDR format :
                                                        // ["127.0.0.1", "::ffff:127.0.0.1", "::1", 
"::ffff:192.168.3.0/28"],

useHttps: false,        // Support HTTPS or not, default "false" will use HTTP
httpsPrivateKey: "",    // HTTPS private key path, only require when useHttps is true
httpsCertificate: "",   // HTTPS Certificate path, only require when useHttps is true

language: "en",
locale: "en-US",
logLevel: ["INFO", "LOG", "WARN", "ERROR", "DEBUG"], // Add "DEBUG" for even more logging
timeFormat: 24,
units: "metric",
// serverOnly:  true/false/"local" ,
// local for armv6l processors, default
//   starts serveronly and then starts chrome browser
// false, default for all NON-armv6l devices
// true, force serveronly mode, because you want to.. no UI on this device

modules: [
    {
        module: "alert",
    },
    {
        module: "updatenotification",
        position: "top_bar"
    },
    {
        module: "clock",
        position: "top_left"
    },
    {
        module: "MMM-GooglePhotos",
        position: "middle_center",
        config: {
                albums: "MagicMirror", // Set your album name. like ["My wedding", "family share", "Travle to Paris"]
                updateInterval: 1000 * 60, // minimum 10 seconds.
                sort: "new", // "old", "random"
                uploadAlbum: null, // Only album created by `create_uploadable_album.js`.
                debug: true,
                condition: {
                    fromDate: null, // Or "2018-03", RFC ... format available
                    toDate: null, // Or "2019-12-25",
                    minWidth: null, // Or 400
                    maxWidth: null, // Or 8000
                    minHeight: null, // Or 400
                    maxHeight: null, // Or 8000
                    minWHRatio: null,
                    maxWHRatio: null,
                    // WHRatio = Width/Height ratio ( ==1 : Squared Photo,   < 1 : Portraited Photo, > 1 : Landscaped 
Photo)
                },
                showWidth: 1080, // These values will be used for quality of downloaded photos to show. real size to 
show in your MagicMirror region is recommended.
                showHeight: 1920,
                timeFormat: "YYYY/MM/DD HH:mm", // Or `relative` can be used.
        }
        },

    /*
    {
        module: "calendar",
        header: "US Holidays",
        position: "top_left",
        config: {
            calendars: [
                {
                    symbol: "calendar-check",
                    url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics"                   }
            ]
        }
    },
    {
        module: "compliments",
        position: "lower_third"
    },
    {
        module: "weather",
        position: "top_right",
        config: {
            weatherProvider: "openweathermap",
            type: "current",
            location: "New York",
            locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and 
find your city
            apiKey: "YOUR_OPENWEATHER_API_KEY"
        }
    },
    {
        module: "weather",
        position: "top_right",
        header: "Weather Forecast",
        config: {
            weatherProvider: "openweathermap",
            type: "forecast",
            location: "New York",
            locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and 
find your city
            apiKey: "YOUR_OPENWEATHER_API_KEY"
        }
    },
    */
    {
        module: "newsfeed",
        position: "bottom_bar",
        config: {
            feeds: [
                {
                    title: "New York Times",
                    url: "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml"
                }
            ],
            showSourceTitle: true,
            showPublishDate: true,
            broadcastNewsFeeds: true,
            broadcastNewsUpdates: true
        }
    },
]
};
aneaville commented 3 years ago

Thanks again. Its easy to start get frustrated about now. I want to give you hope. Things look good, but there is one small thing holding you up. I'm not sure what the small thing is yet.

First thing this does is to get the list of albums you have in your google photos. Then it compares the one in your configuration and scans all the photos from it.

Your error is happening at the very first step of getting the list of albums from the google api. I can see that the token is getting refreshed and that you have the API enabled. However the error is still 403, which means "forbidden". This points to an access issue.

Some simple things to rule out: How many albums do you have? Are any of those albums 'shared with you'? I haven't seen this before, but some very old issues reference something like that. I assumed the used didn't have the ability to scan someone else's album. Is the email used for the magic mirror the same that owns the photo album?

Last thing I would like to verify for now is your client ID. Does yours look like this: image

ericgeezzle commented 3 years ago

Thank you for getting back to me quickly each time i really appreciate it. Dont worry, i wont be discouraged i even hope to do more projects in the future. To answer your questions: In the google photo library there is only one album which i just created. there are other pictures there just not in an album. The email used in the magic mirror is also the owner of the photo album. I dont know about sharing the album because the email is the same as stated above. At the OAuth screen i did select TV... but named it other client1.

2021-09-17-162138_1920x1080_scrot

aneaville commented 3 years ago

Ok. Next step I would like to zero in on the lines of code that are failing. Leave debug: true in your config. On the pi, open GPhotos.js with any editor.

about line 216 - 'var response = await this.request(token, type, "get", params, null)', hit enter and add this.log(response). This should display the response with extra info that comes back from google. Maybe there is a clue in it.

I'm not confident that this will show up. If it interprets the 403 response as an error, it might not display. We'll see. The info we are looking for should come just after [GPHOTOS:CORE] Getting Album info chunks.

If the response isn't helpful, I next want to see what info goes into the request. At line 165, change to this: if (data) config.data = data this.log(config) Axios(config).then((ret)=>{

This should show the what data went into the request, and again should be right after the 'getting album info chunk' line in the log.

ericgeezzle commented 3 years ago

Ok, i have inserted text at line 216 as advised and this is the output

[18.09.2021 16:58.53.930] [LOG]   [GPHOTOS] Starting Initialization
[18.09.2021 16:58.53.932] [LOG]   [GPHOTOS] Getting album list
[18.09.2021 16:58.53.940] [LOG]   [GPHOTOS:AUTH] Token is expired.
[18.09.2021 16:58.54.161] [LOG]   Create new newsfetcher for url: 
https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml - Interval: 300000
[18.09.2021 16:58.54.176] [INFO]  Checking git for module: MMM-GooglePhotos
[18.09.2021 16:58.56.997] [LOG]   [GPHOTOS:AUTH] Token is refreshed.
[18.09.2021 16:58.56.998] [LOG]   [GPHOTOS:CORE] Getting Album info chunks.
[18.09.2021 16:58.59.352] [ERROR] Failed to fetch git data for MMM-GooglePhotos: Error: block timeout reached
[18.09.2021 16:59.04.099] [LOG]   [GPHOTOS:CORE] Error: Request failed with status code 403
[18.09.2021 16:59.04.117] [ERROR] (node:1419) UnhandledPromiseRejectionWarning: Error: Request failed with status code 
403
at createError (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_modules/axios/lib/core/createError.js:16:15)
at settle (/home/pi/MagicMirror/modules/MMM-GooglePhotos/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/home/pi/MagicMirror/modules/MMM- 
GooglePhotos/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
[18.09.2021 16:59.04.119] [ERROR] (node:1419) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This 
error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not 
handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled- 
rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
[18.09.2021 16:59.04.121] [ERROR] (node:1419) [DEP0018] DeprecationWarning: Unhandled promise rejections are 
deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Is this helpful or shall i go to the next step?

ericgeezzle commented 3 years ago

Here's the output of changing after line 165

[18.09.2021 17:09.32.019] [LOG]   All module helpers loaded.
[18.09.2021 17:09.32.108] [LOG]   Starting server on port 8080 ... 
[18.09.2021 17:09.32.123] [LOG]   Server started ...
[18.09.2021 17:09.32.125] [LOG]   Connecting socket for: updatenotification
[18.09.2021 17:09.32.126] [LOG]   Connecting socket for: MMM-GooglePhotos
[18.09.2021 17:09.32.127] [LOG]   Connecting socket for: newsfeed
[18.09.2021 17:09.32.127] [LOG]   Starting node helper for: newsfeed
[18.09.2021 17:09.32.128] [LOG]   Sockets connected & modules started ...
[18.09.2021 17:09.32.404] [LOG]   Launching application.
[18.09.2021 17:09.34.403] [LOG]   [GPHOTOS] Starting Initialization
[18.09.2021 17:09.34.404] [LOG]   [GPHOTOS] Getting album list
[18.09.2021 17:09.34.414] [LOG]   [GPHOTOS:AUTH] Token is alive.
[18.09.2021 17:09.34.418] [LOG]   [GPHOTOS:CORE] Getting Album info chunks.
[18.09.2021 17:09.34.433] [LOG]   [GPHOTOS:CORE] {
  method: 'get',
  url: 'albums',
  baseURL: 'https://photoslibrary.googleapis.com/v1/',
  headers: {
    Authorization: 'Bearer 

[longstringtokenhere]' }, params: { pageSize: 50, pageToken: '' } } [18.09.2021 17:09.34.632] [LOG] Create new newsfetcher for url: https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml - Interval: 300000 [18.09.2021 17:09.34.644] [INFO] Checking git for module: MMM-GooglePhotos [18.09.2021 17:09.40.120] [LOG] [GPHOTOS:CORE] Error: Request failed with status code 403 [18.09.2021 17:09.40.126] [ERROR] (node:1578) UnhandledPromiseRejectionWarning: Error: Request failed with status code 403

Hope these can point us in right diection.

aneaville commented 3 years ago

The error stopped it before the log. On to the next phase.

ericgeezzle commented 3 years ago

Yeah, I did that, check my last comment. I implemented the next phase. i.e. changes made to line 165

aneaville commented 3 years ago

great. in that request is a bearer token. This is your temporary access token. It only lasts about 1 hour. So repeat this and copy the token. Lets say your token is asfadsfasdf123456.

On your pi, open a browser and go to: https://photoslibrary.googleapis.com/v1/albums?access_token=asfadsfasdf123456 But paste your token in instead.

This is essentially what the program is trying to do, but errors out. What response do you get from google?

Couple things I've been thinking about: When you got the 'refresh token' and had to verify it. Did you do that on the pi? What country are you in? I remember reading something about the API not working in all countries. I can't find this info again even after searching for it.

ericgeezzle commented 3 years ago

This is what i used as the token on the browser

 " ya29.a0ARrdaM9qfJfI7n3A0rw0ZGtLk1fRK5P5kHJaiZLpkO3nkAoAO05Vk61N4KIh46K- 
_U5JRDaSaRjE3SPW922SNb8bZzrWHUOlpQI8ZlY8MWHMPn80mrqmpRQivkU1q15XmnKAAHYIPdTsXz3K2P 
cjWOwR9M3gg"

The resulting error is:

{
  "error": {
   "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other 
valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "CREDENTIALS_MISSING",
        "domain": "googleapis.com",
        "metadata": {
         "service": "photoslibrary.googleapis.com",
          "method": "ListAlbums"
        }
      }
    ]
  }

By verify do you mean like when google authentication came up saying someone's trying to access... i did that, i think it was when the authentication comes up first time when trying to access the album. I am in Nigeria. I hope that is not the problem.

aneaville commented 3 years ago

reason - credential missing. This makes me think there was something wrong with the URL, or the token wasn't recognized as a token.

Try again with the URL making sure to keep everything before the = and paste your token in. If you could share the whole URL here, I could help debug.

Secondly, if it wasn't recognized as a token, lets try to get a new one. First get rid of the existing token.json by either renaming or deleting. Then follow the "Get token.json" instructions in the readme. I would even make a new Oath client ID. After generating the new token.json, see if there is any change. If still no luck, are you able to see any different responses from the browser method above using your new token?

Lastly, when posting your token here, try to obscure it. Theoretically someone could use that token to view your photos, though only for like 30 min, and I think there are protections in place if a different computer try's to use your token.

ericgeezzle commented 3 years ago

I hope i am not becoming a bother... Thank you for your patience. I'd like you to help debug This is the whole url https://photoslibrary.googleapis.com/v1/albums?access_token=Bearer%20ya29.a0ARrdaM_rt-smREJzBKJYFSWQnGINAV0wKKrI064-tTUjYjdy5JCC3eClIheWfd3XjswtsDoslLHKAtmMw-B2Ly_0GQl-OofSbYWXruU0HjvNXNWcF0dUvPgMjwQ-nX6uGZQ2Q1_mC-0mS4aXSIF7SDubQPOk

i got a new token and new OAuth same output

aneaville commented 3 years ago

The 'token' does not include "Bearer". Try excluding that. It will just be ya29......to the end.

ericgeezzle commented 3 years ago

https://photoslibrary.googleapis.com/v1/albums?access_token=ya29.a0ARrdaM-PtfyDNQK9GMuBZjhFxoOkEyKuPhVCEbkLWpLSQb-I3cgAGh0cy_OqvxqC6O5XOEpOe5fBdIaVsKQpSIaZ-UfCXiRNThVhgJHClou5lYwbcfoKGKcDI5Z71k4Sdc5XQGMkYw8bsNLhMVSJIp2NXeBN

{
  "albums": [
    {
      "id": "AOdL0tKCZYGigkrjVIOzG6lB0lg6jNrmQBQb5WBDvJUkQsA_ZclH9agbFNzTImj_E_kqri0rcFhJ",
      "title": "MagicMirror",
      "productUrl": 
 "https://photos.google.com/lr/album/AOdL0tKCZYGigkrjVIOzG6lB0lg6jNrmQBQb5WBDvJUkQsA_ZclH9agbFNzTImj_E_
kqri0rcFhJ",
      "mediaItemsCount": "5",
      "coverPhotoBaseUrl": 
"https://lh3.googleusercontent.com/lr/AFBm1_YpPmPDScq6ae0FR5EIIMrYW5KJJp7wRv9vEoPpOMULJLZjhViVIDGqmJd
w8cgfaPmF4FbBowWM6TjCSMy6c-Zt1LZmSY11NEg7NHJv0q4Geg-JNpKFPPoeSrqu8Ahvo- 
PWObfMfwxzD1DCarewoI5d9cDqpH2Ly5Sm- 
XHaj7BQPG_s8rfZsKC7XvYF4yUJEa61e0KjN1NKlu2A7e2mbhfxBApuIGBiFJs__pHaR2Zox9HThx6ojB4fPjDuPASCUZp
4qd_yLhVosuDHECzz-0M-Jnuo7aGg7tSg2xz71CBnqsvFe1Kh1FZP8933Y6itT2Tpb9zfuM4x18RBNKlo0p35sg9c- 
P0EAfmVE0rGG1UqIB3hKJai5pquknfQPlbEX15tQQVoa3PzlVczlLPP5xxtk7ahAvnaXU5C0TU8BdYRyCKoYHjnYRf_Z
2NxUpikjJ8rH0LHRZuGxGk- 
vUIW2WxHxUjUZh7w3E35slRX3uElfXhrRxBDBXo4tUFTSZsmC5KVX4fGW1cRUYBQemZI9XTLshZowdEzq6PvCg0Xo
DVQWhpcDtjaAgCcjcEKsUedmrnqp9Vs2wsgD8_GsHMdudFdCzGakFMLHyKeZUOm2wd7dBGlb8DozjBsF-OiqtE- 
3CAiNY00i6DzjJqoLfWhXWzQKYVgLyutuVdzCFc5An5eGXFzbQJzhF9DI_jXyDMYeY2hc3Ng3uio48PTgAwrnoAWBSV
MXhYvOFqqhn6M3AXGL-TIS2yQ9cfaDuVMqYqqpjBTCAlTrRMIBabpOKgs36OYt_IjX90SST6eMvV6BIxQ5Pi8AtCW
dYvVcl-6-E4fSUtFLhyPJVjhT3u49bp9yk5SmzH0nMuX44pPVg",
      "coverPhotoMediaItemId": "AOdL0tKx20vjOfydbs2NL0tHarsO259WTU8e6JTmJdd9nRUBh- 
     KwawSPp52xNkVG1v4tW78cDJyPyI2YxwGh6Gf1snPAep9lRg"
        }
     ]
  }

looks like it got the album info here. but the display is still blank.

aneaville commented 3 years ago

That is good news. Does your log file still show 403 errors?

I'm really confused how the browser could get the correct response, but the app would get a 403 error.

ericgeezzle commented 3 years ago

No 403 error anymore, only this

[19.09.2021 22:28.07.946] [INFO]  Checking git for module: MMM-GooglePhotos
[19.09.2021 22:28.09.133] [LOG]   [GPHOTOS:CORE] ReferenceError: log is not defined
[19.09.2021 22:28.09.136] [ERROR] (node:908) UnhandledPromiseRejectionWarning: ReferenceError: log is not defined
    at getAlbum (/home/pi/MagicMirror/modules/MMM-GooglePhotos/GPhotos.js:218:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[19.09.2021 22:28.09.137] [ERROR] (node:908) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This 
error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not 
handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled- 
rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
[19.09.2021 22:28.09.138] [ERROR] (node:908) [DEP0018] DeprecationWarning: Unhandled promise rejections are 
deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
aneaville commented 3 years ago

reading the error is good practice. In the GPhotos.js, I had you add a log near line 218. Check that it doesn't look wierd. If you can't see what is wrong with it, then delete it and try again.

This looks like the app did get a response back now and the log crashed it before it could continue.

ericgeezzle commented 3 years ago

Removed the line 218 "log(response)". The error now is below.

[20.09.2021 01:34.06.060] [LOG]   [GPHOTOS:CORE] {
  method: 'get',
  url: 'sharedAlbums',
  baseURL: 'https://photoslibrary.googleapis.com/v1/',
  headers: {
    Authorization: 'Bearer ya29.a0ARrdaM_85RT5Wgl4iaWQdSKDMbokS0WpDGYmj7yqpRGaZ03hsljh-mSt4_scyE- 
  a3HaPylh7KWNhIxR0l6viPwsVz3f5g3LwoCc8dGADI_UiTnexwGcAUOZ90cV8cIsKfq4tIBmoTGElvMBLsgwXsu0w0NZyfg'
  },
  params: { pageSize: 50, pageToken: '' }

[20.09.2021 01:34.07.059] [LOG]   [GPHOTOS] Can't find "M" in your album list.
[20.09.2021 01:34.07.061] [LOG]   [GPHOTOS] Can't find "a" in your album list.
[20.09.2021 01:34.07.062] [LOG]   [GPHOTOS] Can't find "g" in your album list.
[20.09.2021 01:34.07.063] [LOG]   [GPHOTOS] Can't find "i" in your album list.
[20.09.2021 01:34.07.065] [LOG]   [GPHOTOS] Can't find "c" in your album list.
[20.09.2021 01:34.07.067] [LOG]   [GPHOTOS] Can't find "M" in your album list.
[20.09.2021 01:34.07.068] [LOG]   [GPHOTOS] Can't find "i" in your album list.
[20.09.2021 01:34.07.069] [LOG]   [GPHOTOS] Can't find "r" in your album list.
[20.09.2021 01:34.07.070] [LOG]   [GPHOTOS] Can't find "r" in your album list.
[20.09.2021 01:34.07.072] [LOG]   [GPHOTOS] Can't find "o" in your album list.
[20.09.2021 01:34.07.075] [LOG]   [GPHOTOS] Can't find "r" in your album list.
[20.09.2021 01:34.07.079] [LOG]   [GPHOTOS] Finish Album scanning. Properly scanned : 0
[20.09.2021 01:34.07.082] [LOG]   [GPHOTOS] Initialized
[20.09.2021 01:34.07.093] [LOG]   [GPHOTOS] Initialization complete!
[20.09.2021 01:34.07.096] [LOG]   [GPHOTOS] Start first scanning.
[20.09.2021 01:34.07.100] [LOG]   [GPHOTOS] Start Album scanning
[20.09.2021 01:34.07.104] [LOG]   [GPHOTOS] There is no album to get photos.
[20.09.2021 01:34.07.112] [LOG]   [GPHOTOS] unable to load cache [Error: ENOENT: no such file or directory, open 
'/home/pi/MagicMirror/modules/MMM-GooglePhotos/cache/photoListCache.json'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/pi/MagicMirror/modules/MMM-GooglePhotos/cache/photoListCache.json'
}
[20.09.2021 01:35.07.106] [LOG]   [GPHOTOS] Used last pic in list
[20.09.2021 01:35.07.108] [LOG]   [GPHOTOS] num to ref:  0 , DesChunk:  20 , totalLength:  0 , Pntr:  0
[20.09.2021 01:35.07.110] [LOG]   [GPHOTOS] couldn't send  0  pics

there honestly is an album titled "MagicMirror" in the google photos library, the web response found the album, and it is shared. I spell checked it, any ideas why the app can't the album?

ericgeezzle commented 3 years ago

I noticed thar before 'url' used to read 'albums' but now reads 'sharedAlbums' could that be a factor?

aneaville commented 3 years ago

First it scans albums(which it did successfully), then it scans 'shared albums'(which also looks successful).

Now it appears your config has the album name separated by spaces or commas and is looking for each letter at a time. Check the config and see if that is the case. If it looks fine, delete and retype it.

ericgeezzle commented 3 years ago

This is what the config looks like

{
        module: "MMM-GooglePhotos",
        position: "middle_center",
        config: {
                albums: "Test", // Set your album name. like ["My wedding", "family share", "Travle to Paris"]
                updateInterval: 1000 * 60, // minimum 10 seconds.
                sort: "new", // "old", "random"
                uploadAlbum: null, // Only album created by `create_uploadable_album.js`.
                debug: true,
                condition: {
                    fromDate: null, // Or "2018-03", RFC ... format available
                    toDate: null, // Or "2019-12-25",
                    minWidth: null, // Or 400
                    maxWidth: null, // Or 8000
                    minHeight: null, // Or 400
                    maxHeight: null, // Or 8000
                    minWHRatio: null,
                    maxWHRatio: null,
                    // WHRatio = Width/Height ratio ( ==1 : Squared Photo,   < 1 : Portraited Photo, > 1 : Landscaped Photo)
                },
                showWidth: 1080, // These values will be used for quality of downloaded photos to show. real size to show in your MagicMirror region is recommended.
                showHeight: 1920,
                timeFormat: "YYYY/MM/DD HH:mm", // Or `relative` can be used.
        }

I retyped the initial album "MagicMirror" same error then as you can see above i then created a new album "Test", and changed the entry in config, same error.

aneaville commented 3 years ago

Try changing the albums from "test" to ["test"]. so the line will be: albums: ["Test"], // Set your al...

You are very close.

ericgeezzle commented 3 years ago

Yup... virtual hug n virtual hi5... :))) Photos are displayed now. You was so patient, thank you. Can i get your email to correspond later. Im at ericgngis@gmail.com

All that is left is to play around with position. it currently isnt centralized though i selected middle center.

aneaville commented 3 years ago

Glad you got it going.

Before closing the issue, any thoughts on what the fix was? I suspect deleting the old token and getting a new one is what actually fixed the original issue. If you could provide any insight into something that might have been different, it would help future issues.

There are several tips on formatting the pictures using CSS in the readme. Start there for picture placement.

And your politeness and quick response made it much easier to help. If you have other problems in the future, feel free to open a new issue.

ericgeezzle commented 3 years ago

Hmmnnn....The fix. I was wondering about that too, because i did refresh the token and OAuth before now and it didn't work. Though this time while doing that, i enabled Google plus API. I saw it in the read me that it might be necessary. so maybe that was it.

Other than that, cant really think of anything else.

I remain extremely grateful for your assistance and will like to continue corresponding on other stuff, so if new issues arise, i will open one.