הרשאה ואימות
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מומלץ מאוד להשתמש בחשבון שירות לאימות במהלך השילוב עם
SAS Portal API. אם צריך,
יוצרים חשבון שירות. חשוב לבחור ב-JSON כסוג המפתח בעת
יצירת המפתח של חשבון השירות. בסיום ההורדה, המפתח של חשבון השירות יורד למיקום ברירת המחדל של הדפדפן. בנוסף, חשוב
להעניק את התפקיד 'מירכאות; בעלים ופרויקט; לחשבון השירות.
לאחר מכן, עליך לספק את אימות חשבון השירות כאסימון רשת. אם מתקשרים אל
SAS Portal API באופן ישיר, למשל באמצעות בקשת HTTP עם cURL
, מעבירים את האימות כאסימון רשת בכותרת Authorization
. כדי לקבל אסימון רשת
בחשבון השירות, יש לבצע את הפעולות הבאות:
-
מתקינים את כלי שורת הפקודה
gcloud
.
-
מבצעים אימות בחשבון השירות. בפקודה הבאה, צריך להחליף את
${KEY_FILE} בנתיב לקובץ מפתח השירות של חשבון השירות שלך:
gcloud auth activate-service-account --key-file ${KEY_FILE}
-
כדי לקבל אסימון הרשאה, צריך להשתמש בחשבון השירות:
gcloud auth print-access-token
הפקודה מחזירה ערך של אסימון גישה.
-
כשמשתמשים ב-API, צריך להעביר את ערך האסימון כאסימון של כותרת בכותרת Authorization
. דוגמה:
curl -X GET -H "X-Goog-User-Project: ${CLIENT_PROJECT}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${TOKEN}" \
"https://sasportal.googleapis.com/v1alpha1/customers"
מגדירים את ${CLIENT_PROJECT} כ-
ID של פרויקט Google Cloud שממנו אתם שולחים את הבקשות, ולאחר מכן מגדירים את
${TOKEN} לאסימון ההרשאות.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2022-09-26 (שעון UTC).
[[["התוכן קל להבנה","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"]],["עדכון אחרון: 2022-09-26 (שעון UTC)."],[[["Service accounts are the recommended authentication method for integrating with the SAS Portal API, requiring the creation of a service account with a JSON key and granting it the \"Project Owner\" role."],["Authentication to the SAS Portal API is done using a Bearer token obtained through the `gcloud` command-line tool by activating the service account and printing an access token."],["When calling the API, include the Bearer token in the `Authorization` header of your request along with the `X-Goog-User-Project` header specifying your Google Cloud Project ID."]]],["The key actions are creating a service account with a JSON key, granting it the \"Project Owner\" role, and obtaining a Bearer token for API authentication. This is done by installing the `gcloud` tool, authenticating the service account using `gcloud auth activate-service-account --key-file`, and generating an access token via `gcloud auth print-access-token`. This token should then be included in the `Authorization` header when making API calls as a Bearer token.\n"]]