The Picker API provides a secure way for your users to select photos and videos from their Google Photos library and share them with your application.
Before you start
- Check out the overview: Compare the Picker API and the Library API to make sure the Picker API is the right fit for your use case.
- Configure your app: Enable the API and set up authentication. See Configure your app for detailed steps.
The Picker API flow
Here is an overview of the how the Picker API works:
Check for OAuth token: Before starting the Picker API flow, check for a valid OAuth 2.0 access token for the user. If there is no token, initiate the OAuth 2.0 authorization flow to obtain one.
Create a session: Initiate the process by making a call to the Picker API to create a new session. This call will return a unique
pickerUri
.Direct users to the Google Photos app: Provide the
pickerUri
to your users (either as a clickable link or a QR code). This URL will securely open their Google Photos app.User selects media items: Within the Google Photos app, users can browse their library and select the photos and videos they want to share with your app. Read an overview of the user's picking experience.
Poll the session: Your app should periodically poll the session to check the status. You're looking for the
mediaItemsSet
property to return true, indicating the user has finished their selection.List selected media items: Once
mediaItemsSet
returns true, you can use the list method to get details about the selected media items.Retrieve and use media items: Now you have access to the selected media items. You can fetch their content using the
baseUrl
and utilize them within your application.
Next steps
- Review the reference docs: Explore the detailed Picker API reference documentation to learn about all the available methods and parameters.
- Try out the samples: Check out our sample to see the Picker API in action and get inspiration for your integration.