APIهای Google Fit، از جمله Google Fit REST API، در سال 2026 منسوخ خواهند شد . از 1 می 2024، توسعه دهندگان نمی توانند برای استفاده از این API ها ثبت نام کنند .
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
هر درخواستی که برنامه شما به API تناسب اندام ارسال می کند باید شامل یک نشانه مجوز باشد. توکن همچنین برنامه شما را در گوگل شناسایی می کند.
پروتکل مجوز
برنامه شما باید از OAuth 2.0 برای تأیید درخواست ها استفاده کند. هیچ پروتکل مجوز دیگری پشتیبانی نمی شود. اگر برنامه شما از Google Sign-In استفاده می کند، برخی از جنبه های مجوز برای شما انجام می شود.
انواع دادههایی که برنامه شما میخواهد به آن دسترسی داشته باشد با محدودهها مطابقت دارند. قبل از اینکه بتوانید به انواع داده دسترسی داشته باشید، باید تشخیص دهید که آیا محدوده مربوط به آنها حساس یا محدود است و مراحل مربوطه را هنگام درخواست تأیید دنبال کنید. مرحله 3 مجوز درخواستها را در زیر ببینید.
تأیید درخواست ها با OAuth 2.0
همه درخواستها به Fitness API باید توسط یک کاربر تأیید شده مجاز باشد.
جزئیات فرآیند مجوز یا «جریان» برای OAuth 2.0 به نوع برنامه ای که می نویسید بستگی دارد. این فرآیند کلی برای همه انواع برنامه اعمال می شود:
وقتی برنامه خود را ایجاد میکنید، آن را با استفاده از Google API Console ثبت کنید. سپس Google اطلاعاتی را که بعداً به آن نیاز خواهید داشت، مانند شناسه مشتری و راز مشتری ارائه می دهد.
Fitness API را در Google API Console فعال کنید. (اگر API در لیست API Console نیست، از این مرحله صرفنظر کنید.)
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eAll requests to the Google Fitness API require an OAuth 2.0 authorization token to identify your application and grant access.\u003c/p\u003e\n"],["\u003cp\u003eApplications need to be registered using the Google API Console, activate the Fitness API, and potentially undergo a verification process depending on the requested data types and their sensitivity.\u003c/p\u003e\n"],["\u003cp\u003eAccess to user data is granted through a user consent screen, providing your application with a short-lived access token upon approval.\u003c/p\u003e\n"],["\u003cp\u003eData type access corresponds to specific scopes, necessitating review of scope requirements for your application's desired functionalities.\u003c/p\u003e\n"]]],[],null,["# Authorizing Requests\n\nEvery request your application sends to the Fitness API must include an\nauthorization token. The token also identifies your application to Google.\n\nAuthorization protocol\n----------------------\n\nYour application must use [OAuth\n2.0](https://developers.google.com/identity/protocols/oauth2) to authorize\nrequests. No other authorization protocols are supported. If your application\nuses [Google Sign-In](https://developers.google.com/identity/#google-sign-in),\nsome aspects of authorization are handled for you.\n\nThe [data types](/fit/datatypes) your app wants to access correspond to\n[scopes](/fit/datatypes#authorization_scopes). Before you can access data types,\nyou'll need to identify if their corresponding scopes are [sensitive or\nrestricted](/fit/datatypes#authorization_scopes) and follow the relevant steps\nwhen [applying for verification](/fit/verification).\nSee step 3 of [authorizing requests](#authorizing_requests_with_oauth_20) below.\n\nAuthorizing requests with OAuth 2.0\n-----------------------------------\n\nAll requests to the Fitness API must be authorized by an authenticated user.\n\nThe details of the authorization process, or \"flow,\" for OAuth 2.0 will\ndepend on the kind of app you're writing. This general process applies to all\napp types:\n\n1. When you create your application, register it using the [Google API\n Console](https://console.developers.google.com/). Google then provides information you'll need later, such as a client ID and a client secret.\n2. Activate the Fitness API in the Google API Console. (If the API isn't listed in the API Console, then skip this step.)\n3. [Apply for verification](/fit/verification) and submit the relevant supporting information for why your app needs certain scopes. The [data types](/fit/datatypes) your app needs to access correspond to [scopes your app needs to request](/fit/datatypes#authorization_scopes).\n4. If your app is verified, Google displays a consent screen to the user, asking them to authorize your app to access their data.\n5. If the user approves, then Google gives your application a short-lived access token.\n6. Your application requests user data, attaching the access token to the request.\n7. If Google determines that your request and the token are valid, it returns the requested data.\n\n| **Note:** Some flows include additional steps, such as using refresh tokens to acquire new access tokens. For detailed information about flows for various types of applications, see Google's [OAuth 2.0\n| documentation](https://developers.google.com/identity/protocols/oauth2).\n\nRead about the OAuth scopes for the Fitness API\n[here](https://developers.google.com/identity/protocols/oauth2/scopes#fitness).\nLook up [which scope is needed for each data type](/fit/datatypes)."]]