سيتم إيقاف واجهات برمجة تطبيقات Google Fit نهائيًا في عام 2026، بما في ذلك واجهة برمجة التطبيقات Google Fit REST API. اعتبارًا من 1 أيار (مايو) 2024، لن يتمكّن المطوّرون من الاشتراك لاستخدام واجهات برمجة التطبيقات هذه.
للحصول على تعليمات حول واجهة برمجة التطبيقات أو المنصة التي تريد نقل البيانات إليها، يُرجى الانتقال إلى دليل نقل البيانات في Health Connect. للاطّلاع على مقارنة بين Health Connect وGoogle Fit API وFitbit Web API، يُرجى الانتقال إلى دليل مقارنة Health Connect.
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
نظرة عامة
لاستخدام تطبيق Google Fit على Android، تحتاج إلى معرِّف عميل OAuth 2.0 لتطبيقات Android.
يتم توقيع جميع تطبيقات Android باستخدام شهادة رقمية تمتلك
مفتاحها الخاص. يُرجى الرجوع إلى دليل Android لتوقيع تطبيقاتك
لمزيد من المعلومات عن الشهادات الرقمية.
تكون معرّفات عملاء OAuth على Android مرتبطة بمجموعات معيّنة من الشهادات/الحِزم. تحتاج
فقط إلى معرّف واحد لكل شهادة، بغض النظر عن عدد مستخدمي
التطبيق.
يتطلب الحصول على رقم تعريف لتطبيقك اتّباع عدة خطوات. يمكنك الاطّلاع على هذه الخطوات أدناه.
ابحث عن معلومات شهادة تطبيقك.
أنشئ مشروعًا أو عدِّله في "وحدة تحكّم واجهة برمجة تطبيقات Google".
اطلب الحصول على معرِّف عميل OAuth 2.0.
العثور على معلومات شهادة تطبيقك
يستند مفتاح واجهة برمجة التطبيقات إلى نموذج مختصر لشهادة تطبيقك الرقمية، ويُعرف باسم مرجع SHA-1. لعرض الملف المرجعي لشهادة SHA-1
، تأكَّد أولاً من استخدام الشهادة
الصحيحة. قد يكون لديك شهادتان:
شهادة تصحيح الأخطاء: تنشئ أدوات حزمة تطوير البرامج (SDK) لنظام التشغيل Android
هذه الشهادة تلقائيًا عند إنشاء إصدار لتصحيح الأخطاء. لا تستخدِم
هذه الشهادة إلا مع التطبيقات التي تختبرها.
لا تحاول نشر تطبيق موقَّع باستخدام شهادة تصحيح أخطاء.
يمكنك الاطّلاع على مزيد من التفاصيل حول شهادة تصحيح الأخطاء في التوقيع
في وضع تصحيح الأخطاء ضمن مستندات مطوّري تطبيقات Android.
شهادة الإصدار: تنشئ أدوات حزمة SDK لنظام التشغيل Android
هذه الشهادة عند إنشاء إصدار علني. يمكنك أيضًا إنشاء
هذه الشهادة باستخدام برنامج keytool. استخدِم هذه الشهادة عندما
تكون مستعدًا لإصدار تطبيقك للجميع.
اتّبِع الخطوات التالية لعرض بصمة SHA-1 للشهادة باستخدام
برنامج keytool مع المَعلمة -v. لمزيد من
المعلومات حول Keytool، يُرجى الاطّلاع على
مستندات Oracle.
شهادة تصحيح الأخطاء
عرض الملف المرجعي لشهادة تصحيح الأخطاء
حدِّد موقع ملف تخزين مفاتيح تصحيح الأخطاء. اسم الملف هو
debug.keystore، ويتم إنشاؤه في المرة الأولى التي تُنشئ فيها
مشروعك. يتم تخزينه تلقائيًا في الدليل نفسه الذي تتوفّر فيه ملفات "جهاز Android
العامودي (AVD)":
macOS وLinux: ~/.android/
Windows Vista وWindows 7: C:\Users\your_user_name\.android\
إدراج بصمة SHA-1:
بالنسبة إلى نظام التشغيل Linux أو macOS، افتح نافذة محطة طرفية وأدخِل ما يلي:
حدِّد مكان ملف تخزين مفاتيح شهادة الإصدار. لا يتوفّر موقع أو اسم تلقائيان
لمستودع مفاتيح الإصدار. إذا لم تحدّد توقيعًا عند
إنشاء تطبيقك لإصداره، سيبقى
.apk غير موقَّع، وسيكون عليك توقيعه قبل أن تتمكّن من
نشره. بالنسبة إلى شهادة الإصدار، ستحتاج أيضًا إلى اسم البديل
للشهادة وكلمات مرور ملف تخزين المفاتيح والشهادة. يمكنك إدراج
الأسماء البديلة لجميع المفاتيح في مخزن مفاتيح من خلال إدخال:
keytool-list-keystoreyour_keystore_name
استبدِل your_keystore_name بالمسار المُحدَّد بالكامل
واسم ملف تخزين المفاتيح، بما في ذلك اللاحقة .keystore. سيُطلب منك إدخال كلمة مرور ملف تخزين المفاتيح. بعد ذلك، يعرض
keytool جميع الأسماء البديلة في مخزن المفاتيح.
استبدِل your_keystore_name بالمسار المُحدَّد بالكامل
واسم ملف تخزين المفاتيح، بما في ذلك اللاحقة .keystore. استبدِل your_alias_name بالاسم المستعار الذي assigned قدّمته للشهادة عند إنشائها.
بدلاً من ذلك، اتّبِع الخطوات التالية لتفعيل واجهة برمجة التطبيقات Fitness API في
وحدة تحكّم واجهة برمجة تطبيقات Google والحصول على معرّف عميل OAuth 2.0.
انقر على إنشاء. سيظهر معرّف العميل وسر العميل الجديدان لبروتوكول OAuth 2.0 على Android في
قائمة أرقام تعريف مشروعك. معرِّف عميل OAuth 2.0 هو سلسلة من
الأحرف، على النحو التالي:
تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eTo use Google Fit for Android, you need an OAuth 2.0 client ID linked to your app's certificate and package name.\u003c/p\u003e\n"],["\u003cp\u003eBefore requesting a client ID, obtain your app's SHA-1 fingerprint from its debug or release certificate using the \u003ccode\u003ekeytool\u003c/code\u003e program.\u003c/p\u003e\n"],["\u003cp\u003eRequest an OAuth 2.0 client ID through the Google API Console by creating or selecting a project, enabling the Fitness API, and providing your app's SHA-1 fingerprint and package name.\u003c/p\u003e\n"]]],[],null,["# Get an OAuth 2.0 Client ID\n\nOverview\n--------\n\nTo use the Google Fit for Android, you need an OAuth 2.0 client ID for\nAndroid applications.\n\nAll Android apps are signed with a digital certificate for which you hold the\nprivate key. Refer to the [Android guide to signing your applications](//developer.android.com/tools/publishing/app-signing.html)\nfor more information about digital certificates.\n\nAndroid OAuth client IDs are linked to specific certificate/package pairs. You\nonly need one ID for each certificate, no matter how many users you have for\nthe app.\n\nGetting an ID for your app requires several steps. These steps are outlined\nbelow.\n\n1. Find your app's certificate information.\n2. Create or modify a project in the Google API Console.\n3. Request an OAuth 2.0 client ID.\n\nFind your app's certificate information\n---------------------------------------\n\nThe API key is based on a short form of your app's digital certificate,\nknown as its **SHA-1 fingerprint**. To display the SHA-1\nfingerprint for your certificate, first ensure that you are using the right\ncertificate. You may have two certificates:\n\n- **A debug certificate** : The Android SDK tools generate this certificate automatically when you do a debug build. Only use this certificate with apps that you're testing. Do not attempt to publish an app that's signed with a debug certificate. The debug certificate is described in more detail in [Signing\n in Debug Mode](https://developer.android.com/tools/publishing/app-signing.html#debug-mode) in the Android Developer Documentation.\n- **A release certificate** : The Android SDK tools generate this certificate when you do a release build. You can also generate this certificate using the `keytool` program. Use this certificate when you are ready to release your app to the world.\n\nFollow the steps below to display a certificate's SHA-1 fingerprint using\nthe `keytool` program with the `-v` parameter. For more\ninformation about Keytool, see the\n[Oracle documentation](http://docs.oracle.com/javase/6/docs/technotes/tools/windows/keytool.html).\nDebug certificate \n\n### Displaying the debug certificate fingerprint\n\n1. Locate your debug keystore file. The file name is\n `debug.keystore`, and is created the first time you build your\n project. By default, it is stored in the same directory as your Android\n Virtual Device (AVD) files:\n\n - **macOS and Linux** : `~/.android/`\n - **Windows Vista and Windows 7** : `C:\\Users\\your_user_name\\.android\\`\n2. List the SHA-1 fingerprint:\n\n - For Linux or macOS, open a terminal window and enter the following:\n\n ```gdscript\n keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android\n ```\n - For Windows Vista and Windows 7, run:\n\n ```gdscript\n keytool -list -v -keystore \"%USERPROFILE%\\.android\\debug.keystore\" -alias androiddebugkey -storepass android -keypass android\n ```\n\nYou should see output similar to this: \n\n```carbon\nAlias name: androiddebugkey\nCreation date: Jan 01, 2013\nEntry type: PrivateKeyEntry\nCertificate chain length: 1\nCertificate[1]:\nOwner: CN=Android Debug, O=Android, C=US\nIssuer: CN=Android Debug, O=Android, C=US\nSerial number: 4aa9b300\nValid from: Mon Jan 01 08:04:04 UTC 2013 until: Mon Jan 01 18:04:04 PST 2033\nCertificate fingerprints:\n MD5: AE:9F:95:D0:A6:86:89:BC:A8:70:BA:34:FF:6A:AC:F9\n SHA1: BB:0D:AC:74:D3:21:E1:43:07:71:9B:62:90:AF:A1:66:6E:44:5D:75\n Signature algorithm name: SHA1withRSA\n Version: 3\n```\nRelease certificate \n\n### Displaying the release certificate fingerprint\n\n1. Locate your release certificate keystore file. There is no default\n location or name for the release keystore. If you don't specify one when\n you build your app for release, the build will leave your\n `.apk` unsigned, and you'll have to sign it before you can\n publish it. For the release certificate, you also need the certificate's\n alias and the passwords for the keystore and the certificate. You can list\n the aliases for all the keys in a keystore by entering:\n\n ```gdscript\n keytool -list -keystore your_keystore_name\n ```\n\n Replace *`your_keystore_name`* with the fully-qualified\n path and name of the keystore, including the `.keystore`\n extension. You'll be prompted for the keystore's password. Then\n `keytool` displays all the aliases in the keystore.\n2. Enter the following at a terminal or command prompt:\n\n ```gdscript\n keytool -list -v -keystore your_keystore_name -alias your_alias_name\n ```\n\n Replace *`your_keystore_name`* with the fully-qualified\n path and name of the keystore, including the `.keystore`\n extension. Replace *`your_alias_name`* with the alias that\n you assigned to the certificate when you created it.\n\nYou should see output similar to this: \n\n```carbon\nAlias name: \u003calias_name\u003e\nCreation date: Feb 02, 2013\nEntry type: PrivateKeyEntry\nCertificate chain length: 1\nCertificate[1]:\nOwner: CN=Android Debug, O=Android, C=US\nIssuer: CN=Android Debug, O=Android, C=US\nSerial number: 4cc9b300\nValid from: Mon Feb 02 08:01:04 UTC 2013 until: Mon Feb 02 18:05:04 PST 2033\nCertificate fingerprints:\n MD5: AE:9F:95:D0:A6:86:89:BC:A8:70:BA:34:FF:6B:AC:F9\n SHA1: BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:90:AF:A1:66:6E:44:5D:75\n Signature algorithm name: SHA1withRSA\n Version: 3\n```\n\nThe line that begins with `SHA1` contains the certificate's SHA-1\nfingerprint. The fingerprint is the sequence of 20 two-digit hexadecimal\nnumbers separated by colons.\n| **Caution:** To protect your keystore and key, don't enter the `storepass` or `keypass` arguments on the command line unless you're confident of your computer's security. For example, on a public computer, someone could look at your terminal window history or list of running processes, get the password, and then have write access to your signing certificate. This would allow that person to modify or replace your app with their own.\n\nRequest an OAuth 2.0 client ID in the Google API Console\n--------------------------------------------------------\n\nFollow these steps to create or modify a project for your app in the\nGoogle API Console, enable the Fitness API, and request an OAuth 2.0 client ID.\n\nIf you want to be guided through the process and activate the\nFitness API automatically, click\n\n[Get a Client ID](https://console.cloud.google.com/flows/enableapi?apiid=fitness)\n\nAlternatively, follow these steps to enable the Fitness API in the\nGoogle API Console and get an OAuth 2.0 client ID.\n\n1. Go to the [Google API Console](https://console.cloud.google.com/flows/enableapi?apiid=fitness).\n2. Select a project, or create a new one. Use the same project for the Android and REST versions of your app.\n3. Click **Continue** to enable the Fitness API.\n4. Click **Go to credentials**.\n5. Click **New credentials** , then select **OAuth Client ID**.\n6. Under **Application type** select **Android**.\n7. In the resulting dialog, enter your app's SHA-1 fingerprint and package\n name. For example:\n\n `BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75`\n\n `com.example.android.fit-example`\n8. Click **Create**. Your new Android OAuth 2.0 Client ID and secret appear in\n the list of IDs for your project. An OAuth 2.0 Client ID is a string of\n characters, something like this:\n\n `780816631155-gbvyo1o7r2pn95qc4ei9d61io4uh48hl.apps.googleusercontent.com`"]]