This guide explains how to use Google Picker API features such as turning on multi-select, hiding the navigation pane, and choosing the user account with the app's current OAuth 2.0 token.
Prerequisites
For this example, you need to specify several items:
To locate both the Client ID and the API Key:
In the Google Cloud console, go to Menu > APIs & Services > Credentials.
To locate the App ID:
In the Google Cloud console, go to Menu > IAM & Admin > Settings.
Use the project number for the app ID.
The same Google Cloud project must contain both the client ID and the app ID as it's used to authorize access to a user's files.
Create the app
The following code sample shows how to use an image selector or upload page that users can open from a button in a web app.
The setOAuthToken
function allows an app to use the current auth token to
determine which Google Account the Google Picker uses to display the files. If
a user is signed in with multiple Google Accounts, the Google Picker can
display the files of the appropriate authorized account.
After obtaining the file ID from the Google Picker when opening files, an app
can then fetch the file metadata and download the file content as described in
the get
method of the files
resource.