授權要求
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
應用程式傳送至 Google AMP URL API 的每項要求都必須向 Google 識別您的應用程式。使用應用程式的 API 金鑰來識別應用程式。
取得並使用 API 金鑰
API 金鑰必須隨附向 Google AMP URL API 發出的公開資料要求。
API 金鑰可用來識別您的專案,並提供 API 存取權、配額和報表。
如要取得 API 金鑰,請按照下列步驟操作:
- 開啟「憑證」頁面。
- 建立及使用伺服器金鑰。請勿在伺服器程式碼外使用這組金鑰。例如,不要嵌入網頁。為避免配額遭竊,請將金鑰限制為只允許來自伺服器的要求 (來源 IP 位址)。
為確保 API 金鑰安全無虞,請遵循安全使用 API 金鑰的最佳做法。
建立 API 金鑰後,您的應用程式可將查詢參數 key=yourAPIKey
附加至所有要求網址。
API 金鑰可以安全地嵌入網址中,不需任何編碼。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2023-08-30 (世界標準時間)。
[null,null,["上次更新時間:2023-08-30 (世界標準時間)。"],[[["\u003cp\u003eEvery request sent to the Google AMP URL API must identify your application using an API key.\u003c/p\u003e\n"],["\u003cp\u003eObtain an API key through the Google Developers Console, specifically a Server key, and restrict its usage to your server's IP addresses for security.\u003c/p\u003e\n"],["\u003cp\u003eInclude your API key in all request URLs as a query parameter (\u003ccode\u003ekey=yourAPIKey\u003c/code\u003e), which is safe for embedding without encoding.\u003c/p\u003e\n"]]],["To interact with the Google AMP URL API, obtain an API key from the Credentials page. Create a Server key and restrict it to your server's IP addresses for security. Append the `key=`yourAPIKey parameter to all request URLs. This key identifies your project, grants API access, and provides quota and reports. Do not embed the key outside of server code, as it's designed for server-side use. Refer to the linked best practices for securely managing your API key.\n"],null,["# Authorize Requests\n\nEvery request your application sends\nto the Google AMP URL API needs\nto identify your application to Google.\nIdentify your application using the application's\n[API key](https://developers.google.com/console/help/generating-dev-keys).\n\nAcquire and use an API key\n--------------------------\n\nAn [API key](https://developers.google.com/console/help/generating-dev-keys)\nmust accompany requests to the Google AMP URL API for public data.\n\nThe API key identifies your project and provides API access, quota, and reports.\nTo acquire an API key, do the following:\n\n1. Open the [Credentials page](https://console.developers.google.com/apis/credentials?project=_).\n2. Create and use a **Server key**. Do not use this key outside of your server code. For example, do not embed it in a web page. To prevent quota theft, restrict your key so that requests are only allowed from your servers' source IP addresses.\n\nTo keep your API keys secure, follow the\n[best practices for securely using\nAPI keys](https://developers.google.com/console/help/api-key-best-practices).\n\nAfter you have an API key,\nyour application can append the query parameter\n`key=`yourAPIKey\nto all request URLs.\n\nThe API key is safe for embedding in URLs; it doesn't need any encoding."]]