google_photos 1.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 43

Google Photos Autogenerated API client #

Google Photos does not yet have a first-party Dart SDK, so this is an unofficial API client autogenerated from Google Photo's API discovery doc

Caveat lector: Although this library is completely autogenerated using discoveryapis_generator, it is also not tested. I'm using it in my own projects and have not run into any problems, but please open an issue if you run into any problems.

Getting Started #

This API client is designed to be used with Dart's standard HTTP library. However, most of the endpoints require authentication headers to function properly.

Flutter #

You can use the google_sign_in package to get these headers, and extend the HTTP BaseClient to inject the auth headers on behalf of the API client. See the example directory.

In future, perhaps the Dart or Flutter teams will provide better integration of HTTP clients with the google_sign_in package.

Everything else #

Use the existing googleapis_auth library to get an authenticated HTTP client.

[1.0.4] - Re-relased without deprecation

[1.0.3] - Errantly deprecated in favor of Google packge (not available)

[1.0.2] - Moved example to fit analysis requirements, and updated homepage to point to github repo

[1.0.1] - Small update to pubspec to improve score and organization.

[1.0.0] - Google Photos v1 API

  • Initial release of autogenerated Google Photos API client. Generated from the v1 discovery doc


import 'package:google_photos/google_photos.dart';
import 'package:http/http.dart';
import 'package:google_sign_in/google_sign_in.dart';

main() async {
  final GoogleSignIn googleSignIn = GoogleSignIn(scopes: <String>[
  final user = await googleSignIn.signInSilently();
  final client = AuthenticatedClient(
    () => user.authHeaders,
  final api = PhotoslibraryApi(client);
  // ... use API

class AuthenticatedClient extends BaseClient {
  final Client baseClient;
  final Future<Map<String, String>> Function() getAuthHeaders;
  final Future<void> Function() invalidHeadersCallback;


  Future<StreamedResponse> send(final BaseRequest request) async {
    var authHeaders = await getAuthHeaders();
    var response = await baseClient.send(request);
    if (response.statusCode == 401) {
      // Headers are expired, or perhaps user has been logged out.
      // GoogleSignIn expects clients to inform it of invalid cached headers.
      await invalidHeadersCallback();
    return response;

  void close() {

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  google_photos: ^1.0.4

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:google_photos/google_photos.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Fix lib/api_client/photoslibrary.dart. (-25 points)

Analysis of lib/api_client/photoslibrary.dart reported 214 hints, including:

line 43 col 35: Unnecessary new keyword.

line 44 col 43: Unnecessary new keyword.

line 46 col 7: Unnecessary new keyword.

line 49 col 27: Use = to separate a named parameter from its default value.

line 50 col 30: Use = to separate a named parameter from its default value.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
_discoveryapis_commons >=0.1.0 <0.2.0 0.1.9
http >=0.11.1 <0.13.0 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
discoveryapis_generator ^0.9.11