New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/gphotosuploader/google-photos-api-client-go/v2

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/gphotosuploader/google-photos-api-client-go/v2

  • v2.4.2
  • Source
  • Go
  • Socket score

Version published
Created
Source

Google Photos API client for Go

Go Reference Go Report Card codebeat badge codecov GitHub release GitHub

This package provides a client for using the Google Photos API in go. Uses the original photoslibrary package, that was provided by Google and now it's maintained here.

The package offers access to these Google Photos services:

  • CachedAlbumsService is a service to manage albums.
  • MediaItemsService is a service to manage media items (Photos and Videos).
  • Uploader is a service to upload items.

This project will maintain compatibility with the last three Go major versions published.

Installation

$ go get github.com/gphotosuploader/google-photos-api-client-go/v2

Features

The package could be consumed using three different services in isolation or a gphotos.Client. It implements Google Photos error handling best practices. It uses an exponential backoff policy with a maximum of 5 retries.

CachedAlbumsService

Uploader

  • Offers two uploaders implementing the /v1/uploads endpoint.
    • BasicUploader is a simple HTTP uploader.
    • ResumableUploader is an uploader implementing resumable uploads. It could be used for large files, like videos. See documentation.

Authentication

The gphotos library does not directly handle authentication. Instead, when creating a new client, pass an http.Client that can handle authentication for you. The easiest and recommended way to do this is using the golang.org/x/oauth2 library, but you can always use any other library that provides an http.Client.

Access to the API requires OAuth client credentials from a Google developers project. This project must have the Library API enabled as described here.

import (
    "golang.org/x/oauth2"

    gphotos "github.com/gphotosuploader/google-photos-api-client-go/v2"
)

func main() {
    ctx := context.Background()
    oc := oauth2Config := oauth2.Config{
        ClientID:     "... your application Client ID ...",
        ClientSecret: "... your application Client Secret ...",
        // ...
    }
    tc := oc.Client(ctx, "... your user Oauth Token ...")
    client := gphotos.NewClient(tc)
}

Note that when using an authenticated Client, all calls made by the client will include the specified OAuth token. Therefore, authenticated clients should almost never be shared between different users. See the oAuth2 docs for complete instructions on using that library.

Limitations

Only images and videos can be uploaded. If you attempt to upload non videos or images or formats that Google Photos doesn't understand, Google Photos will give an error when creating media item.

Photo storage and quality

All media items uploaded to Google Photos using the API are stored in full resolution at original quality. They count toward the user’s storage. The API does not offer a way to upload in "high quality" mode.

Duplicates

If you upload the same image (with the same binary data) twice then Google Photos will deduplicate it. However it will retain the filename from the first upload which may be confusing. In practise this shouldn't cause too many problems.

Albums

Note that you can only add media items that have been uploaded by this application to albums that this application has created, see here why.

Rate Limiting

Google Photos imposes a rate limit on all API clients. The quota limit for requests to the Library API is 10,000 requests per project per day. The quota limit for requests to access media bytes (by loading a photo or video from a base URL) is 75,000 requests per project per day.

Used by

FAQs

Package last updated on 10 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc