新しい Picker API と Library API の重要な変更点について説明します。詳しくは、
こちらをご覧ください。
Method: sessions.create
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
新しいセッションを生成します。このセッション中に、ユーザーはサードパーティによるアクセス対象の写真や動画を選択できます。
ユーザーが有効な Google フォト アカウントを持っていない場合、FAILED_PRECONDITION
エラーが返されます。
クライアント アプリケーションがユーザーあたりのセッションを作成した数が多すぎると、RESOURCE_EXHAUSTED
エラーが返されます。通常の状況では、クライアントがこれらの上限に達することはありません。ただし、リソースの上限内に収まるように事前に対策を講じるため、クライアントは各セッションの後に sessions.delete
を呼び出すことをおすすめします。
ユーザーが [完了] ボタンをタップしてピッキング セッションを完了すると、pickerUri
は機能しなくなります。ユーザーがさらに写真を選べるように、新しいセッションを作成します。
HTTP リクエスト
POST https://photospicker.googleapis.com/v1/sessions
この URL は gRPC Transcoding 構文を使用します。
クエリ パラメータ
パラメータ |
requestId |
string
省略可。このリクエストの一意の識別子(クライアント提供)。 この ID は、入力が制限されたデバイスで OAuth 2.0 フローを使用するアプリケーションで、選択作業を効率化するために使用されます。 この ID は UUID(バージョン 4)文字列の形式で、次の要件を満たしている必要があります。
- ユーザーの機密性の高い個人情報は含めないでください。
- 32 桁の 16 進数を 5 つのグループに分割し、ハイフンで区切った「xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx」(または 8-4-4-4-12)の形式で指定する必要があります。
|
リクエストの本文
リクエストの本文には PickingSession
のインスタンスが含まれます。
レスポンスの本文
成功した場合、レスポンスの本文には、新しく作成された PickingSession
のインスタンスが含まれます。
認可スコープ
次の OAuth スコープが必要です。
https://www.googleapis.com/auth/photospicker.mediaitems.readonly
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-25 UTC。
[null,null,["最終更新日 2025-07-25 UTC。"],[[["\u003cp\u003eThis endpoint creates a session for users to select photos and videos for third-party access.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eFAILED_PRECONDITION\u003c/code\u003e error occurs if the user lacks an active Google Photos account.\u003c/p\u003e\n"],["\u003cp\u003eExcessive session creation leads to a \u003ccode\u003eRESOURCE_EXHAUSTED\u003c/code\u003e error, though unlikely under normal use.\u003c/p\u003e\n"],["\u003cp\u003eClients should call \u003ccode\u003esessions.delete\u003c/code\u003e after each session to avoid exceeding resource limits.\u003c/p\u003e\n"],["\u003cp\u003eRequires the \u003ccode\u003ehttps://www.googleapis.com/auth/photospicker.mediaitems.readonly\u003c/code\u003e OAuth scope for authorization.\u003c/p\u003e\n"]]],["This describes the creation of a new session for users to grant third-party access to their photos and videos. It uses a `POST` request to `https://photospicker.googleapis.com/v1/sessions`. The request body contains a `PickingSession` instance, and a successful response returns a new `PickingSession`. Requires `photospicker.mediaitems.readonly` OAuth scope. Errors include `FAILED_PRECONDITION` for inactive accounts and `RESOURCE_EXHAUSTED` for excessive session creation. Deleting sessions with `sessions.delete` is recommended to manage resources.\n"],null,["# Method: sessions.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n\nGenerates a new session during which the user can pick photos and videos for third-party access.\n\nIf the user doesn't have an active Google Photos account, a `FAILED_PRECONDITION` error is returned.\n\nIf the client application creates too many sessions per user, a `RESOURCE_EXHAUSTED` error is returned. Clients are unlikely to reach these limits under normal circumstances. However, clients are still recommended to call `sessions.delete` after each session, to proactively stay within resource limits.\n\nOnce [a user taps the **Done**](https://developers.google.com/photos/picker/guides/picking-experience#done_screen) button to complete a picking session, the `pickerUri` will no longer work. Create a new session to allow the user to pick more photos.\n\n### HTTP request\n\n`POST https://photospicker.googleapis.com/v1/sessions`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Query parameters\n\n| Parameters ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `requestId` | `string` Optional. A client-provided unique identifier for this request. This ID is used to enable the streamlined picking experience for applications using the OAuth 2.0 flow for limited-input devices. This ID must have the format of a UUID (version 4) string and follow these requirements: - Must not contain any sensitive identifying information about the user. - Must contain 32 hexadecimal characters divided into five groups separated by hyphens, in the format \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\" (or 8-4-4-4-12). |\n\n### Request body\n\nThe request body contains an instance of [PickingSession](/photos/picker/reference/rest/v1/sessions#PickingSession).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [PickingSession](/photos/picker/reference/rest/v1/sessions#PickingSession).\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/photospicker.mediaitems.readonly`"]]