בדף הזה מוסבר איך להשתמש במפתחות API כדי לגשת ל-API ולשירותים שמקבלים מפתחות API. Cloud de Confiance by S3NS
לא כל ממשקי ה-API מקבלים מפתחות API לצורך אישור השימוש. Cloud de Confiance by S3NS כדי לדעת אם מוצעת תמיכה למפתחות API, מומלץ לעיין במאמרי העזרה של השירות או של ה-API.
מידע על יצירה וניהול של מפתחות API, כולל הגבלת מפתחות API, זמין במאמר ניהול מפתחות API.
לפני שמתחילים
Select the tab for how you plan to use the samples on this page:
C#
כדי להשתמש בסביבת פיתוח מקומית בדוגמאות של .NET שבדף הזה, מתקינים ומפעילים את ה-CLI של gcloud, ואז מגדירים את Application Default Credentials באמצעות פרטי הכניסה של המשתמש.
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
Create local authentication credentials for your user account:
gcloud auth application-default login
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
למידע נוסף, ראו הגדרת ADC לסביבת פיתוח מקומית במאמרי העזרה בנושא אימות Cloud de Confiance .
C++
כדי להשתמש בסביבת פיתוח מקומית בדוגמאות של C++ שבדף הזה, מתקינים ומפעילים את ה-CLI של gcloud, ואז מגדירים את Application Default Credentials באמצעות פרטי הכניסה של המשתמש.
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
Create local authentication credentials for your user account:
gcloud auth application-default login
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
למידע נוסף, ראו הגדרת ADC לסביבת פיתוח מקומית במאמרי העזרה בנושא אימות Cloud de Confiance .
Go
כדי להשתמש בסביבת פיתוח מקומית בדוגמאות של Go שבדף הזה, מתקינים ומפעילים את ה-CLI של gcloud, ואז מגדירים את Application Default Credentials באמצעות פרטי הכניסה של המשתמש.
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
Create local authentication credentials for your user account:
gcloud auth application-default login
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
למידע נוסף, ראו הגדרת ADC לסביבת פיתוח מקומית במאמרי העזרה בנושא אימות Cloud de Confiance .
Node.js
כדי להשתמש בסביבת פיתוח מקומית בדוגמאות של Node.js שבדף הזה, מתקינים ומפעילים את ה-CLI של gcloud, ואז מגדירים את Application Default Credentials באמצעות פרטי הכניסה של המשתמש.
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
Create local authentication credentials for your user account:
gcloud auth application-default login
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
למידע נוסף, ראו הגדרת ADC לסביבת פיתוח מקומית במאמרי העזרה בנושא אימות Cloud de Confiance .
Python
כדי להשתמש בסביבת פיתוח מקומית בדוגמאות של Python שבדף הזה, מתקינים ומפעילים את ה-CLI של gcloud, ואז מגדירים את Application Default Credentials באמצעות פרטי הכניסה של המשתמש.
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
Create local authentication credentials for your user account:
gcloud auth application-default login
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
למידע נוסף, ראו הגדרת ADC לסביבת פיתוח מקומית במאמרי העזרה בנושא אימות Cloud de Confiance .
REST
כדי להשתמש בדוגמאות של API בארכיטקטורת REST שבדף הזה בסביבת פיתוח מקומית, צריך להשתמש בפרטי הכניסה שאתם נותנים ל-CLI של gcloud.
Install the Google Cloud CLI, and then sign in to the gcloud CLI with your federated identity.
מידע נוסף מופיע במאמר אימות לשימוש ב-REST במסמכי האימות של Cloud de Confiance .
שימוש במפתח API באמצעות REST
כדי לכלול מפתח API בקריאה ל-API בארכיטקטורת REST, משתמשים בכותרת x-goog-api-key HTML.
אם אי אפשר להשתמש בכותרת HTTP, אפשר להשתמש בפרמטר השאילתה key.
עם זאת, בשיטה הזו מפתח ה-API נכלל בכתובת ה-URL, ולכן הוא חשוף לסריקות של כתובות URL.
שימוש במפתח API באמצעות ספריות לקוח
בזמן השימוש במפתחות API באפליקציות שלכם, צריך לוודא שהן מאובטחות במהלך האחסון ובמהלך ההעברה. חשיפת מפתחות ה-API באופן ציבורי עלולה לגרום לחיובים לא צפויים בחשבון שלכם. מידע נוסף זמין במאמר שיטות מומלצות לניהול מפתחות API.