קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
בקטע 'פרטי כניסה' בכלי APIs Explorer אפשר לבדוק עם פרטי כניסה והיקפים שונים. התכונה הזו שימושית כדי לוודא שאתם משתמשים בפרטי הכניסה ובהיקף ההרשאות המינימליים שנדרשים להפעלת נקודת קצה של API.
בדיקה עם פרטי כניסה שונים
כברירת מחדל, המערכת בודקת את סוגי פרטי הכניסה OAuth 2 ומפתח API.
אם רוצים לבדוק רק עם פרטי כניסה אחדים, מסמנים את סוג פרטי הכניסה שרוצים להשתמש בו (ומבטלים את הסימון של סוג פרטי הכניסה האחר). אלה הכללים הכלליים לבחירת פרטי כניסה לבדיקה:
אם אתם משתמשים בשיטה לגישה לנתונים ציבוריים, כמו נתונים של מפות Google, אתם יכולים להשתמש במפתח API כפרטי הכניסה שלכם. מסמנים את האפשרות API key ומבטלים את הסימון של Google OAuth 2.0.
אם אתם משתמשים בשיטה לגישה לנתונים פרטיים, כמו נתונים ב-Google Drive של המשתמש, אתם צריכים להשתמש באמצעי אימות OAuth 2. מבטלים את הסימון של API key ומסמנים את Google OAuth 2.0.
אם מקבלים תוצאה של 200, פרטי הכניסה מספיקים כדי לגשת לנתונים. אם מקבלים תוצאה של 401, צריך להשתמש בפרטי כניסה של OAuth 2 כדי לגשת לנתונים.
בדיקה עם היקפים שונים
היקף הוא מחרוזת, כמו https://www.googleapis.com/auth/drive.metadata.readonly, שמגדירה רמת גישה למשאבים שנדרשים לאפליקציה, כמו רמת הגישה לנתונים שבבעלות המשתמשים. מומלץ שהאפליקציה תשתמש בהיקפי הרשאות עם רמת הגישה המצומצמת ביותר לנתוני המשתמש. יכול להיות ששיטות שונות ידרשו היקפים שונים. לדוגמה, יכול להיות ש-method מסוים ב-API ידרוש לפחות היקף הרשאות לקריאה בלבד, בעוד ש-method אחר ידרוש היקף הרשאות לקריאה ולכתיבה.
כברירת מחדל, כל היקפי ההרשאות של Google OAuth 2.0 עבור API מופעלים ב-APIs Explorer. כדי לבצע בדיקה בהיקף ספציפי:
בקטע Credentials Google OAuth 2.0 (פרטי כניסה Google OAuth 2.0), לוחצים על show scopes (הצגת היקפי הרשאות).
בודקים את היקף ההרשאה שצריך להשתמש בו כשמפעילים את השיטה.
לוחצים על Execute כדי להפעיל את ה-API רק עם ההיקף שנבחר. ב-APIs
Explorer מוצג מסך הרשאה שבו מתבקשת הרשאת גישה לשימוש בהיקף.
לוחצים על אישור. התוצאות מופיעות מתחת ללחצן Execute (הפעלה).
אם ב-APIs Explorer מופיעה תוצאה של 200 בקטע application/json, סימן שההיקף מספיק להפעלת ה-method. אם ב-APIs Explorer מוצגת תוצאה של 403, סימן שבחרתם בהיקף לא מספיק להפעלת השיטה. כדאי לנסות היקף רחב יותר.
מידע נוסף על בחירת היקף ההרשאות מופיע בקטע בנושא אימות והרשאה במסמכי התיעוד של ממשק Google API הספציפי.
ביטול גישה מורשית כדי לבצע בדיקה עם היקפי הרשאות חדשים
אחרי שמשתמשים במסך ההרשאות של Google כדי לאשר הרשאה, ל-APIs Explorer יש הרשאה לשלוח בקשות מאומתות כל עוד תוקף פרטי הכניסה לא פג. ביטול הסימון של היקפי ההרשאות לא מאפס את פרטי הכניסה והיקפי ההרשאות שאושרו בעבר. אם רוצים לבדוק עם הגדרת היקף חדשה, צריך לבטל את האישורים שאושרו קודם.
כדי לבטל את פרטי הכניסה שמשמשים את הכלי APIs Explorer:
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-26 (שעון UTC)."],[[["\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."]]