下列程式碼範例使用 Ruby 適用的 Google API 用戶端程式庫YouTube Analytics API。您可以前往 GitHub 上的 YouTube API 程式碼範例存放區的 ruby
資料夾,下載這些程式碼範例。
授權要求
下列程式碼範例會檢查是否包含包含授權憑證的本機檔案,以執行 OAuth 2.0 授權。如果檔案不存在,指令碼會開啟瀏覽器並等待回應,然後將傳回的憑證儲存在本機。
require 'google/api_client' require 'google/api_client/client_secrets' require 'json' require 'launchy' require 'thin' RESPONSE_HTML = <OAuth 2 Flow Complete You have successfully completed the OAuth 2 flow. Please close this browser window and return to your program.