您目前查看的是 Google Photos Library API 的舊版說明文件。
開始使用 REST
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如要開始使用 Google Photos Library API,請透過下列方法啟用 API 以設定專案:
並設定 OAuth 2.0 用戶端 ID。
您的應用程式代表
Google 相簿使用者。例如,當您在使用者的
Google 相簿相片庫或將媒體項目上傳到使用者的
Google 相簿帳戶,使用者透過
OAuth 2.0 通訊協定。
OAuth 2.0 用戶端 ID 可讓應用程式使用者登入、驗證
然後使用 Library APILibrary API 不支援
或服務帳戶如要使用這個 API,使用者必須登入有效的 Google
。
啟用 API
您必須先為專案啟用 Library API,才能使用該 API。
- 前往 Google API 控制台。
- 在選單列中,選取專案或建立新專案。
- 如要開啟 Google API 程式庫,請從導覽選單選取
API 與服務 >程式庫。
- 搜尋「Google Photos Library API」。選取正確的結果並按一下
啟用:
要求 OAuth 2.0 用戶端 ID
請按照下列步驟申請 OAuth 用戶端 ID,並為其進行設定
應用程式。這個範例使用的應用程式,其可存取整個 OAuth 流程
,如我們範例中所示設定程序可能不同
其他導入情境。
- 前往 Google API 控制台
然後選取所需專案
- 從選單中選取「API 與」服務 >憑證。
- 在「Credentials」(憑證) 頁面上,按一下「Create Credentials」(建立憑證) > OAuth 用戶端 ID。
- 選取您的「應用程式類型」。在這個範例中,應用程式類型為
網頁應用程式。
註冊應用程式可存取 Google API 的來源
如下所示:
- 為識別用戶端 ID,請輸入名稱。
在「授權的 JavaScript 來源」欄位中,輸入
應用程式。這個欄位不允許使用萬用字元。
您可以輸入多個來源,讓應用程式在不同的位置執行
通訊協定、網域或子網域您輸入的網址可以
開始 OAuth 要求。
以下範例是本機開發網址 (我們的範例使用
localhost:8080
) 和正式版網址。
http://localhost:8080
https://myproductionurl.example.com
「授權的重新導向 URI」欄位是接收到的端點
OAuth 2.0 伺服器的回應。通常這包括
並指向應用程式中的路徑
http://localhost:8080/auth/google/callback
https://myproductionurl.example.com/auth/google/callback
按一下「建立」。
-
從產生的 OAuth 用戶端對話方塊中,複製以下內容:
您的應用程式可以使用這些值存取已啟用的 Google API。
在啟動可存取 Library API 的公開應用程式之前,
您的應用程式必須經過 Google 審查。「未驗證的應用程式」訊息會出現在
測試應用程式時的畫面
通過驗證。
試用範例
現在您已設定專案,搭配 Library API 使用,
查看 GitHub 上的範例應用程式。範例應用程式
示範如何使用 Library API 打造智慧型相框模式。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-09-12 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間:2024-09-12 (世界標準時間)。"],[[["To use the Google Photos Library API, you must enable the API and set up an OAuth 2.0 client ID through the Google API Console."],["Users must be signed in to a valid Google Account to use the Library API as it requires user authorization via OAuth 2.0 for actions like creating albums or uploading media."],["Before launching publicly, your application needs to be reviewed and verified by Google to remove the \"Unverified app\" message during testing."]]],["To utilize the Google Photos Library API, first enable it for your project in the Google API Console. Then, create an OAuth 2.0 client ID, specifying the application type, authorized JavaScript origins, and redirect URIs. Obtain the client ID and secret from the resulting dialog. Ensure your application is reviewed by Google before public launch. Note, only valid Google Account users can use this API as service accounts aren't supported.\n"]]