To start using the Google Photos Library API, configure your project by enabling the API via the Google API Console and setting up an OAuth 2.0 client ID.
Your application interacts with Google Photos on behalf of a Google Photos user. For instance, when you create albums in a user's Google Photos library or upload media items to a user's Google Photos account, the user authorizes these API requests via the OAuth 2.0 protocol.
The OAuth 2.0 client ID allows your application users to sign in, authenticate, and thereby use the Library API. The Library API does not support service accounts; to use this API, users must be signed in to a valid Google Account.
Configure your app
Enable the API
Before you can use the Library API, you must enable it for your project using one of the below methods:
- Through the shortcut:
- Click the button below.
- Select an existing project or create a new project.
- Through the Google API Console:
- Go to the Google API Console.
- From the menu bar, select a project or create a new project.
- To open the Google API Library, from the Navigation menu, select APIs & Services > Library.
- Search for "Google Photos Library API". Select the correct result and click Enable.
Request an OAuth 2.0 client ID
For a server-side web app, such as the ones shown in our samples, follow the steps below. In this setup, the entire OAuth flow is handled by a server-side application. The setup process may vary for other implementation scenarios.
- Go to the Google API Console and select your project.
- From the menu, select APIs & Services > Credentials.
- On the Credentials page, click Create Credentials > OAuth client ID.
- Select your Application type. In this example, the application type is Web application.
- Register the origins from which your app is allowed to access the Google APIs as follows:
- To identify the client ID, enter a name.
You can enter multiple origins to allow your app to run on different protocols, domains, or subdomains. The URLs you enter are allowed to start an OAuth request.
The following example shows a local development URL (our samples use
localhost:8080) and a production URL.
- The Authorized redirect URI field is the endpoint that receives responses from the
OAuth 2.0 server. Typically, this includes your development environment and points to a
path in your application.
- Click Create.
From the resulting OAuth client dialog, copy the following:
- Client ID
- Client secret
Your app can access the enabled Google APIs using these values.
Before you can launch a public application that accesses the Library API, your app must be reviewed by Google. An "Unverified app" message appears on the screen when you test your application, until it is verified.
Try out the sample
Now that you've configured your project for use with the Library API, check out the sample app on GitHub. The sample app demonstrates how you can build a smart photo frame using the Library API.