مقدمه: برنامه ها را با استفاده از Data Portability API توسعه دهید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Data Portability API به شما امکان میدهد برنامههایی بسازید که درخواست مجوز از کاربر برای انتقال یک نسخه از دادهها از سرویسهای Google به برنامه شما میدهند. این قابلیت حمل داده ها را ممکن می کند و خدمات سوئیچینگ را تسهیل می کند.
همچنین باید بررسی کنید که Data Portability API برای کاربرانی که در مکان شما هستند در دسترس است. برای فهرستی از کشورها و مناطق پشتیبانی شده، به سوالات متداول در صفحه "به اشتراک گذاری یک نسخه از داده های خود با شخص ثالث" مراجعه کنید.
گردش کار برنامه نویس
این مراحلی است که برای ایجاد برنامه ای که از Data Portability API استفاده می کند، دنبال می کنید.
جریان رضایت OAuth را برای کاربر اجرا کنید. در این مثال، کاربر امکان دسترسی به داده های ویدیوی YouTube را فراهم می کند.
کاربر روی Import Videos YouTube کلیک می کند و به حساب Google خود وارد می شود.
برنامه کاربر را به URL رضایت OAuth هدایت می کند. توجه داشته باشید که این URL مثال ساده شده است و برخی از پارامترها را ندارد:
کاربر روی Next در صفحه رضایت OAuth کلیک می کند، با اشتراک گذاری داده های خود موافقت می کند و دسترسی به حساب را فراهم می کند.
کاربر انتخاب میکند چه دادههایی را به اشتراک بگذارد و مدت زمانی را که برنامه میتواند به آن دادهها دسترسی داشته باشد ( دسترسی یکباره به دادههای خود یا دسترسی مبتنی بر زمان برای 30 یا 180 روز)، سپس روی Continue کلیک میکند.
توجه : تا 90 روز قبل از انقضای توکن OAuth شما، کاربر میتواند دسترسی شما به دادههای خود را قبل از منقضی شدن توکن OAuth تمدید کند. اگر کاربر محدوده های منقضی در 90 روز را نداشته باشد، دکمه تمدید ظاهر نمی شود.
توجه : اگر کاربر بخواهد بین دسترسی یکباره و دسترسی مبتنی بر زمان جابجا شود، باید پس از لغو اعطای موجود، دوباره جریان رضایت را طی کند. میتوانید با resetAuthorization() این کمک مالی را لغو کنید، یا کاربر میتواند در صفحه اتصالات خود لغو کند.
کاربر به برنامه هدایت می شود.
توسعه دهنده یک نشانه OAuth برای کاربر دریافت می کند.
برنامه شما InitiatePortabilityArchive(resources = ["myactivity.youtube"]) را با یک نشانه OAuth پیوست که حاوی این محدوده OAuth است فراخوانی می کند:
این فراخوان فرآیند ایجاد آرشیو داده ها را آغاز می کند و با شناسه شغلی و اینکه آیا کاربر به کاربر دسترسی یکباره یا مبتنی بر زمان داده است، پاسخ می دهد.
توجه : دسترسی یکباره به معنای یک صادرات در هر محدوده است. اگر کاربر دامنه های متعددی را اعطا کند، می توانید شغل های جداگانه ای برای هر یک از منابع مجاز توسط توکن ایجاد کنید.
برنامه شما GetPortabilityArchiveState(job_id) با یک نشانه OAuth پیوست شده که شامل این محدوده OAuth است فراخوانی می کند:
برای بازیابی وضعیت کار بایگانی می توانید چندین بار با این روش تماس بگیرید. متد وضعیت کار را برمی گرداند. اگر وضعیت COMPLETE باشد، بایگانی آماده است و نشانیهای اینترنتی ذخیرهسازی ابری امضا شده ارائه میشوند. توجه داشته باشید که زمان تکمیل درخواست بایگانی بسته به اندازه داده ها می تواند از چند دقیقه تا چند ساعت متفاوت باشد.
بایگانی داده ها را با استفاده از URL های امضا شده دانلود کنید.
اگر کاربر یک بار دسترسی اعطا کند ، شما ResetAuthorization() با یک توکن OAuth پیوست شده برای بازنشانی منابع تمام شده و حذف همه رضایتهای OAuth فراخوانی میکنید.
اگر کاربر دسترسی مبتنی بر زمان را اعطا کند ، میتوانید هر 24 ساعت منابع را صادر کنید تا زمانی که رضایت منقضی شود.
نحوه تعامل کاربران با یک برنامه API Portability Data
این نمودار نحوه تعامل کاربران با برنامهای که با Data Portability API یکپارچه شده است را نشان میدهد.
ابتدا گزینه ای برای بازیابی اطلاعات به کاربر ارائه می شود.
در مرحله بعد، کاربر وارد حساب Google خود می شود.
سپس، وقتی از کاربر خواسته میشود دادههای خود را به اشتراک بگذارد، روی Next کلیک میکند، و وقتی از او خواسته میشود که خطمشی رازداری را بپذیرد، روی من میفهمم کلیک میکند.
سپس، یک صفحه رضایت OAuth به کاربر نشان داده میشود که از آن برای دسترسی برنامه به دادههایش استفاده میشود. گزینههای اینجا با دامنههای OAuth که پیکربندی کردهاید مطابقت دارند. کاربر انتخاب میکند چه دادههایی را به اشتراک بگذارد و مدت زمانی را که برنامه میتواند به آن دادهها دسترسی داشته باشد ( دسترسی یکباره به دادههای خود یا دسترسی مبتنی بر زمان برای 30 یا 180 روز)، سپس روی Continue کلیک میکند.
پس از اجازه دسترسی، وارد کردن داده ها شروع می شود. بسته به اندازه داده ها، تکمیل درخواست ممکن است چند دقیقه تا چند ساعت طول بکشد.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe Data Portability API allows developers to build applications that enable users to move a copy of their data from Google services to another application, facilitating service switching.\u003c/p\u003e\n"],["\u003cp\u003eBefore releasing an application using this API, developers must obtain approval from Google and ensure the API is available in the user's region.\u003c/p\u003e\n"],["\u003cp\u003eThe developer workflow involves implementing the OAuth consent flow, initiating the data archive creation, monitoring its status, downloading the archive using provided URLs, and finally resetting authorization.\u003c/p\u003e\n"],["\u003cp\u003eUsers interact with Data Portability API applications by initiating data retrieval, signing into their Google Account, granting necessary permissions, and waiting for the data import process to complete.\u003c/p\u003e\n"],["\u003cp\u003eData Portability API features are not accessible to users under 18 years of age, resulting in an error message if they attempt to use them.\u003c/p\u003e\n"]]],[],null,["# Introduction: Develop apps using the Data Portability API\n\nThe Data Portability API lets you build applications that request authorization from a\nuser to move a copy of data from Google services into your application. This\nenables data portability and facilitates switching services.\n\nIf you are looking for information on how users share data, see [Share a copy of\nyour data with a third party](https://support.google.com/accounts/answer/14452558).\n\nPrerequisites\n-------------\n\nBefore releasing your app, it must be [approved](/data-portability/user-guide/client-verification) by Google.\n\nYou should also verify that the Data Portability API is available to users in\nyour location. For a list of supported countries and regions, see\n[Common Questions](https://support.google.com/accounts/answer/14452558) on the \"Share a copy of your data with a third\nparty\" page.\n\nDeveloper workflow\n------------------\n\nThese are the steps you follow to create an application that uses the\nData Portability API.\n\n1. Implement the OAuth consent flow for the user. In this example, the user is\n providing access to YouTube video data.\n\n 1. The user clicks **Import YouTube Videos** and signs into their Google\n Account.\n\n 2. The app forwards the user to an OAuth consent URL. Note that this\n example URL is simplified and is missing some parameters:\n\n `https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/dataportability.myactivity.youtube`\n 3. The user clicks **Next** on the OAuth consent screen, agrees to share\n their data, and provides account access.\n\n 4. The user selects what data to share and the amount of time the app can\n access that data (*one-time access* to their data or *time-based access* for\n 30 or 180 days), then clicks **Continue**.\n\n **Note**:\n Up to 90 days before your OAuth token expires, the user has the option\n of renewing your access to their data before your OAuth token expires.\n The renew button doesn't appear if the user doesn't have scopes expiring\n within 90 days.\n\n **Note** : If the user wants to switch between *one-time access* and\n *time-based access* they will need to go through the consent flow again\n after the existing grant has been revoked. You can revoke the grant with\n `resetAuthorization()`, or the user can revoke on their [connections\n page](http://myaccount.google.com/connections).\n 5. The user is redirected to the app.\n\n 6. The developer obtains an OAuth token for the user.\n\n2. Your app calls\n `InitiatePortabilityArchive(resources = [\"myactivity.youtube\"])` with\n an attached OAuth token that contains this OAuth scope:\n\n `https://www.googleapis.com/auth/dataportability.myactivity.youtube`\n\n This call starts the process of creating the data archive and responds with\n a job ID and whether the user granted one-time or time-based access.\n\n **Note** :\n One-time access means one export *per scope*. If the user grants\n multiple scopes, you may choose to create separate jobs for each of the\n resources authorized by the token.\n | **Tip:** You should initiate the portability archive within 24 hours of user authorization.\n3. Your app calls `GetPortabilityArchiveState(job_id)` with an attached OAuth\n token that contains this OAuth scope:\n\n `https://www.googleapis.com/auth/dataportability.myactivity.youtube`\n\n You can call this method multiple times to retrieve the status of the\n archive job. The method returns the job's state. If the state is `COMPLETE`,\n the archive is ready, and signed Cloud Storage URLs are provided. Note that\n the time it takes to complete the archive request can vary from minutes to\n hours depending on the size of the data.\n4. Download the data archive using the signed URLs.\n\n5. *If the user grants one-time access* , you call `ResetAuthorization()` with\n an attached OAuth token to reset exhausted resources and to remove all OAuth\n consents.\n\n6. *If the user grants time-based access*, you can export resources every 24\n hours until the consent expires.\n\nFor more information on using the Data Portability API methods, see\n[Call Data Portability API methods](/data-portability/user-guide/methods).\n\nHow users interact with a Data Portability API app\n--------------------------------------------------\n\nThis diagram shows how users interact with an app that's integrated with the\nData Portability API.\n\n1. First, the user is presented with an option to retrieve their data.\n\n2. Next, the user signs into their Google Account.\n\n3. Then, the user clicks **Next** when they're prompted to share their data,\n and they click **I understand** when they're prompted to accept the privacy\n policy.\n\n4. Then, the user is shown an OAuth consent screen that is used to allow the\n application to access their data. The options here match the OAuth scopes\n you configured. The user selects what data to share and the amount of time\n the app can access that data (*one-time access* to their data or\n *time-based access* for 30 or 180 days), then clicks **Continue**.\n\n5. After allowing access, the data import starts. Depending on the size of the\n data, the request can take several minutes to several hours to complete."]]