Method: sessions.create
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
एक नया सेशन जनरेट करता है. इस दौरान, उपयोगकर्ता तीसरे पक्ष को ऐक्सेस देने के लिए फ़ोटो और वीडियो चुन सकता है.
अगर उपयोगकर्ता के पास कोई चालू Google Photos खाता नहीं है, तो FAILED_PRECONDITION
गड़बड़ी का कोड दिखता है.
अगर क्लाइंट ऐप्लिकेशन हर उपयोगकर्ता के लिए बहुत ज़्यादा सेशन बनाता है, तो RESOURCE_EXHAUSTED
गड़बड़ी का मैसेज दिखता है. सामान्य परिस्थितियों में, क्लाइंट इन सीमाओं तक नहीं पहुंच सकते. हालांकि, हमारा सुझाव है कि क्लाइंट हर सेशन के बाद sessions.delete
को कॉल करें, ताकि वे संसाधनों की सीमाओं के अंदर रहें.
चुने गए आइटम को हटाने के लिए, जब कोई उपयोगकर्ता हो गया बटन पर टैप करता है, तो pickerUri
काम नहीं करेगा. उपयोगकर्ता को ज़्यादा फ़ोटो चुनने की अनुमति देने के लिए, नया सेशन बनाएं.
एचटीटीपी अनुरोध
POST https://photospicker.googleapis.com/v1/sessions
यूआरएल में gRPC ट्रांसकोडिंग सिंटैक्स का इस्तेमाल किया गया है.
क्वेरी पैरामीटर
पैरामीटर |
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 और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 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`"]]