ellisda / googlephoto

Google Photos API Client (OAuth 2)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Google Photo API client (Go WebServer)

Here is some sample code that consumes the Google Photos Rest API, using OAuth2 authentication.

Build

go build

Run with a http listener to catch the auth code

./googlephoto

Run solely on command line (user must copy / paste auth code into terminal)

./googlephoto --port 0

Steps to Get Working

Steps to configure OAuth2 client:

  1. Create a new Project at https://console.developers.google.com/apis/library
  2. Select your new project, then find and enable the "Photos Library API" at https://console.developers.google.com/apis/library
  3. Configure new Credentials at https://console.developers.google.com/apis/credentials/
  4. Paste the generated client ID and secret into the client.go file
  5. Run the program, authenticate to google, and grant access to the app
  6. Review your app access grants at https://myaccount.google.com/permissions

Things Left to do

  1. There is an issue in the http listener code where the shutdown doesn't work right and causes a ~30 sec delay when performing auth. Refreshing the redirected browser window kicks it.

  2. We're not detecting expired refresh tokens on disk or refreshing the token against the server. Delete the file on disk as a workaround.

  3. Add some Client API structs and methods for Album/MediaItem routes, maybe with code generation from a swagger spec? (see API reference)

  4. Do something useful (like ask google to provide the "storage quality" in the returned media items)

References

About

Google Photos API Client (OAuth 2)


Languages

Language:Go 100.0%