Access token for Google Photos (oauth2), to a nodejs server script

306 Views Asked by At

I have nodejs server script. I would like to be access the Google API -- specifically, Google Photos. Google Photos API doesn't accept service accounts, but only oauth2. The problem is that I am using this script on a headless server (it's a remote backup script).

I am using this module to authenticate: https://www.npmjs.com/package/googleapis and would like to use this one to access the photos: https://www.npmjs.com/package/googlephotos

I created my Google App, I added the Google Photo API; I then created an Oauth authentication method, and given it the right scopes. However, right now to authenticate I am using a script I run on the terminal, which then open a page -- a modified version of this https://raw.githubusercontent.com/googleapis/google-api-nodejs-client/master/samples/oauth2.js which actually saves the access token.

I would really need the script to deal with authentication by itself. Especially since this is a personal application, and access tokens will tend to expire.

Is this impossible to do?

0

There are 0 best solutions below