با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
بخش اعتبار APIs Explorer به شما امکان می دهد با اعتبارنامه ها و دامنه های مختلف آزمایش کنید. این ویژگی در حصول اطمینان از استفاده از حداقل اعتبار و محدوده مورد نیاز برای فراخوانی نقطه پایانی API مفید است.
با مدارک مختلف تست کنید
به طور پیش فرض، هر دو نوع اعتبار OAuth 2 و API Key بررسی می شوند. اگر میخواهید فقط با یک اعتبار آزمایش کنید، نوع اعتبار مورد استفاده را بررسی کنید (و تیک نوع اعتبار دیگر را بردارید). قوانین کلی برای انتخاب اعتبار برای آزمایش به شرح زیر است:
اگر از روشی برای دسترسی به داده های عمومی استفاده می کنید، مانند داده های Google Maps، می توانید از یک کلید API به عنوان اعتبار خود استفاده کنید. کلید API را علامت بزنید و علامت Google OAuth 2.0 را بردارید.
اگر از روشی برای دسترسی به داده های خصوصی استفاده می کنید، مانند داده های Google Drive کاربر، باید از اعتبارنامه OAuth 2 استفاده کنید. علامت کلید API را بردارید و Google OAuth 2.0 را علامت بزنید.
اگر نتیجه 200 دریافت کردید، اعتبار برای دسترسی به داده ها کافی است. اگر نتیجه 401 را دریافت کردید، باید از اعتبار OAuth 2 برای دسترسی به داده ها استفاده کنید.
تست با دامنه های مختلف
محدوده یک رشته است، مانند https://www.googleapis.com/auth/drive.metadata.readonly ، که سطح دسترسی به منابع مورد نیاز برنامه شما را تعریف می کند، مانند سطح دسترسی به داده های متعلق به کاربران. در حالت ایدهآل، میخواهید برنامه شما از محدودههایی با محدودترین سطح دسترسی به دادههای کاربر استفاده کند. روشهای مختلف ممکن است به حوزههای متفاوتی نیاز داشته باشند. به عنوان مثال، یک روش در یک API ممکن است حداقل به یک محدوده فقط خواندنی نیاز داشته باشد، در حالی که روشهای دیگر ممکن است به محدوده خواندن و نوشتن نیاز داشته باشند.
به طور پیشفرض، همه حوزههای Google OAuth 2.0 برای یک API در APIs Explorer فعال هستند. برای آزمایش با یک محدوده خاص:
در بخش اعتبارنامههای Google OAuth 2.0، روی show scopes کلیک کنید.
محدوده مورد استفاده در هنگام فراخوانی روش را بررسی کنید.
روی Execute کلیک کنید تا API فقط با استفاده از محدوده انتخاب شده اجرا شود. APIs Explorer یک صفحه مجوز را نشان میدهد که از شما میخواهد برای استفاده از محدوده دسترسی بدهید.
روی Allow کلیک کنید. نتایج زیر دکمه Execute ظاهر می شوند.
اگر APIs Explorer نتیجه 200 را تحت یک "application/json" نشان دهد، آنگاه محدوده برای فراخوانی روش کافی است. اگر APIs Explorer نتیجه 403 را نشان دهد، شما محدوده کافی را برای فراخوانی روش انتخاب کرده اید. دامنه وسیع تری را امتحان کنید.
برای اطلاعات بیشتر در مورد انتخاب محدوده، به بخش احراز هویت و مجوز اسناد مربوط به Google API خاص خود مراجعه کنید.
لغو دسترسی مجاز برای آزمایش با دامنههای جدید
پس از اینکه از صفحه مجوز Google برای تأیید مجوز استفاده کردید، APIs Explorer تا زمانی که اعتبارنامه ها منقضی نشده باشند، مجاز به درخواست های تأیید شده باقی می ماند. برداشتن علامت scopes، اعتبارنامهها و محدودههای تایید شده قبلی را بازنشانی نمیکند. اگر میخواهید با پیکربندی دامنه جدید آزمایش کنید، باید اعتبارنامههای تأیید شده قبلی خود را لغو کنید.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe API Explorer's credentials section allows testing with different credentials (API key or Google OAuth 2.0) and scopes to ensure minimal access requirements.\u003c/p\u003e\n"],["\u003cp\u003eAPI keys are suitable for accessing public data, while OAuth 2.0 credentials are necessary for private data access.\u003c/p\u003e\n"],["\u003cp\u003eUsing the scopes feature, you can select specific access levels (read-only, read-write, etc.) and verify their sufficiency for invoking API methods.\u003c/p\u003e\n"],["\u003cp\u003eTo test with new scopes, you may need to revoke previously approved credentials through your Google account settings.\u003c/p\u003e\n"]]],[],null,["# Test with different credential types and scopes\n\nThe APIs Explorer's credentials section lets you test with different\ncredentials and scopes. This feature is useful in ensuring you're using the\nminimal required credentials and scope to invoke an API endpoint.\n\nTest with different credentials\n-------------------------------\n\nBy default, both the OAuth 2 and API Key credential types are checked.\nIf you want to test with only one credential, check on the credential type to\nuse (and uncheck the other credential type). Following are the general rules for\npicking a credential to test with:\n\n- If you're using a method to access public data, such as Google Maps data, you\n can use an API key as your credential. Check **API key** and uncheck\n **Google OAuth 2.0**.\n\n- If you're using a method to access private data, such as the user's Google\n Drive data, you must use an OAuth 2 credential. Uncheck **API key** and check\n **Google OAuth 2.0**.\n\nIf you receive a result of 200, the credential is sufficient\nfor accessing the data. If you receive a result of 401, you need\nto use OAuth 2 credential to access the data.\n\nTest with different scopes\n--------------------------\n\nA scope is a string, such as\n`https://www.googleapis.com/auth/drive.metadata.readonly`, defining a level of\naccess to resources required by your app, such as the level of access to data\nowned by the users. Ideally, you want your app to use scopes with\nthe narrowest level of access to the user's data. Different methods might\nrequire different scopes. For example, a method in an API might require\nat least a read-only scope, while other methods might require a read-write\nscope.\n| **Note:** Scopes are only applicable to Google OAuth 2.0. If you're testing with an API key, you won't test with different scopes.\n\nBy default, all Google OAuth 2.0 scopes for an API are enabled in the APIs\nExplorer. To test with a specific scope:\n\n1. In the Credentials Google OAuth 2.0 section, click **show scopes**.\n2. Check the scope to use when invoking the method.\n3. Click **Execute** to execute the API using only the selected scope. The APIs Explorer shows an authorization screen asking you to grant access to use the scope.\n4. Click **Allow**. The results appear below the Execute button.\n\nIf the APIs Explorer shows a result of 200 under an \"application/json\", then the\nscope is sufficient to invoke the method. If the APIs Explorer shows an\nresult of 403, you have chosen an insufficient scope to invoke the method. Try\na broader scope.\n\nFor additional information on scope selection, refer to the authentication and\nauthorization section of documentation for your specific Google API.\n\n### Revoke authorized access to test with new scopes\n\nAfter you have used the Google authorization screen to approve authorization,\nthe APIs Explorer remains authorized to make authenticated requests as long\nas the credentials aren't expired. Unchecking scopes doesn't reset the\npreviously approved credentials and scopes. If you want to test with a new\nscope configuration, you must revoke your previously approved credentials.\n\nTo revoke the credentials used by the APIs Explorer:\n\n1. Navigate to [Apps with access to your account](https://www.google.com/accounts/IssuedAuthSubTokens).\n2. Under **Third-party apps with account access** , click **Google APIs Explorer**.\n3. Click **Remove Access**.\n4. (optional) Reload the documentation page to reset the APIs Explorer."]]