با Picker API جدید و تغییرات مهم Library API آشنا شوید.
جزئیات اینجا
Method: sessions.create
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
یک جلسه جدید ایجاد می کند که در طی آن کاربر می تواند عکس ها و فیلم ها را برای دسترسی شخص ثالث انتخاب کند.
اگر کاربر یک حساب Google Photos فعال نداشته باشد، یک خطای FAILED_PRECONDITION
برگردانده می شود.
اگر برنامه سرویس گیرنده تعداد جلسات زیادی را برای هر کاربر ایجاد کند، یک خطای RESOURCE_EXHAUSTED
برگردانده می شود. بعید است که مشتریان در شرایط عادی به این محدودیت ها برسند. با این حال، همچنان به مشتریان توصیه می شود که پس از هر جلسه با sessions.delete
تماس بگیرند تا فعالانه در محدوده منابع باقی بمانند.
هنگامی که کاربر برای تکمیل یک جلسه انتخاب، دکمه Done را بزند ، pickerUri
دیگر کار نخواهد کرد. یک جلسه جدید ایجاد کنید تا کاربر بتواند عکس های بیشتری را انتخاب کند.
درخواست HTTP
POST https://photospicker.googleapis.com/v1/sessions
URL از دستور GRPC Transcoding استفاده می کند.
پارامترهای پرس و جو
پارامترها |
---|
requestId | string اختیاری. یک شناسه منحصر به فرد ارائه شده توسط مشتری برای این درخواست. این شناسه برای فعال کردن تجربه انتخاب ساده برای برنامههایی که از جریان OAuth 2.0 برای دستگاههای ورودی محدود استفاده میکنند استفاده میشود. این شناسه باید فرمت یک رشته UUID (نسخه 4) داشته باشد و شرایط زیر را رعایت کند: - نباید حاوی هیچ گونه اطلاعات شناسایی حساس در مورد کاربر باشد.
- باید شامل 32 نویسه هگزا دسیمال باشد که به پنج گروه جدا شده با خط تیره، با قالب "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" (یا 8-4-4-4-12) تقسیم شده اند.
|
درخواست بدن
بدنه درخواست شامل نمونه ای از PickingSession
است.
بدن پاسخگو
در صورت موفقیت آمیز بودن، بدنه پاسخ حاوی نمونه جدیدی از PickingSession
است.
محدوده مجوز
به محدوده OAuth زیر نیاز دارد:
-
https://www.googleapis.com/auth/photospicker.mediaitems.readonly
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\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`"]]