久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <i id='QBYVN'><tr id='QBYVN'><dt id='QBYVN'><q id='QBYVN'><span id='QBYVN'><b id='QBYVN'><form id='QBYVN'><ins id='QBYVN'></ins><ul id='QBYVN'></ul><sub id='QBYVN'></sub></form><legend id='QBYVN'></legend><bdo id='QBYVN'><pre id='QBYVN'><center id='QBYVN'></center></pre></bdo></b><th id='QBYVN'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='QBYVN'><tfoot id='QBYVN'></tfoot><dl id='QBYVN'><fieldset id='QBYVN'></fieldset></dl></div>

    <small id='QBYVN'></small><noframes id='QBYVN'>

      <bdo id='QBYVN'></bdo><ul id='QBYVN'></ul>
    1. <tfoot id='QBYVN'></tfoot>

        <legend id='QBYVN'><style id='QBYVN'><dir id='QBYVN'><q id='QBYVN'></q></dir></style></legend>
      1. 服務應用程序和 Google Analytics API V3:服務器到服務

        Service Applications and Google Analytics API V3: Server-to-server OAuth2 authentication?(服務應用程序和 Google Analytics API V3:服務器到服務器 OAuth2 身份驗證?)
      2. <small id='2g00C'></small><noframes id='2g00C'>

        • <legend id='2g00C'><style id='2g00C'><dir id='2g00C'><q id='2g00C'></q></dir></style></legend>

                <bdo id='2g00C'></bdo><ul id='2g00C'></ul>
                    <tbody id='2g00C'></tbody>

                  <i id='2g00C'><tr id='2g00C'><dt id='2g00C'><q id='2g00C'><span id='2g00C'><b id='2g00C'><form id='2g00C'><ins id='2g00C'></ins><ul id='2g00C'></ul><sub id='2g00C'></sub></form><legend id='2g00C'></legend><bdo id='2g00C'><pre id='2g00C'><center id='2g00C'></center></pre></bdo></b><th id='2g00C'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2g00C'><tfoot id='2g00C'></tfoot><dl id='2g00C'><fieldset id='2g00C'></fieldset></dl></div>
                  <tfoot id='2g00C'></tfoot>
                1. 本文介紹了服務應用程序和 Google Analytics API V3:服務器到服務器 OAuth2 身份驗證?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試制作一個服務器應用程序,以便定期從我自己的 GA 帳戶中提取 Google Analytics(分析)數據.請注意,它是訪問我自己數據的個人服務器端應用程序,即沒有最終用戶訪問此應用程序.

                  I'm trying to make a server application to routinely pull Google Analytics data from my own GA account. Note, it is a personal, server-side application accessing my own data, i.e. there is no end-user accessing this application.

                  因此,我在 Google API 控制臺 中將我的應用程序注冊為服務應用程序,它給了我一個客戶 ID 和一個私鑰.我的理解是,服務應用程序不使用應用程序機密重定向 URL,因為在此服務器到服務器身份驗證流程中沒有最終用戶.事實上,Google API 控制臺沒有給我任何秘密,也沒有提示我輸入重定向 URL.

                  As such, I registered my application in the Google API Console as a Service Application, which gave me a Client ID and a Private Key. It is my understanding that Service Applications do NOT use Application Secret and Redirect URL as there is no end-user in this server-to-server authentication flow. Indeed, the Google API Console gave me no Secret and did not prompt me for a Redirect URL.

                  不幸的是,我無法弄清楚如何在 Google 的內部驗證我的服務應用程序PHP 客戶端 API.有大量關于向最終用戶驗證 Web 應用程序的文檔.

                  Unfortunately, I can not figure out how to authenticate my Service Application within Google's PHP Client API. There is extensive documentation on authenticating web applications with an end-user.

                  Google 的文檔建議 可以通過使用私鑰.我只是不知道如何在 PHP 客戶端 API 中執行(盡管我已經瀏覽了源代碼并且有 絕對是一個用私鑰簽署請求的腳本.)

                  Google's documentation suggests it is possible to authenticate server-to-server by signing a JWT request with the private key. I just can't figure out how to do within the PHP client API (although I've browsed the source and there's definitely a script that signs a request with the private key.)

                  我在這里遺漏了什么嗎?如何使用我的私鑰和 Google PHP 客戶端 API 對服務應用程序執行身份驗證?

                  Am I missing something here? How can I perform authentication for a Service Application with my private key and the Google PHP client API?

                  為清晰起見進行了編輯

                  推薦答案

                  2012 年 7 月 21 日更新

                  Google Analytics API V3 現在支持由 .p12 簽名的 JWT 請求返回的 OAuth2 令牌.也就是說,我們現在可以使用帶有服務帳戶的 Analytics API.

                  目前正在提取 4 年的逐日指標,只是為了它.

                  Currently pulling 4 years of day-by-day metrics, just for the hell of it.

                  這是一個快速的n"步驟:

                  Here's a quick 'n' dirty step-by-step:

                  1. 轉到 Google API 控制臺并創建一個新應用

                  服務標簽中,打開Google Analytics開關

                  API 訪問選項卡中,點擊創建 OAuth2.0 客戶端 ID

                  • 輸入您的姓名,上傳徽標,然后單擊下一步

                  選擇服務帳戶選項,然后按創建客戶 ID

                  下載您的私鑰

                  現在您又回到了API 訪問頁面.您將看到一個名為服務帳戶的部分,其中包含一個客戶 ID電子郵件地址

                  Now you're back on the API Access page. You'll see a section called Service account with a Client ID and Email address

                  • 復制電子郵件地址(類似于####@developer.gserviceaccount.com)

                  訪問您的GA管理員并將此電子郵件添加為用戶到您的屬性

                  這是必須的;否則你會得到神秘的錯誤.

                  This is a must; you'll get cryptic errors otherwise.

                  通過 Github 獲取最新的 Google PHP 客戶端 API

                  Get the latest Google PHP Client API via Github

                  git submodule add https://github.com/google/google-api-php-client.git google-api-php-client-read-only
                  

                2. 搖滾樂(感謝大家提供有關更新類名稱的提示):

                3. Rock 'n' roll (thanks all for tips on updated class names):

                  // api dependencies
                  require_once(PATH_TO_API . 'Google/Client.php');
                  require_once(PATH_TO_API . 'Google/Service/Analytics.php');
                  
                  // create client object and set app name
                  $client = new Google_Client();
                  $client->setApplicationName(APP_NAME); // name of your app
                  
                  // set assertion credentials
                  $client->setAssertionCredentials(
                    new Google_Auth_AssertionCredentials(
                  
                      APP_EMAIL, // email you added to GA
                  
                      array('https://www.googleapis.com/auth/analytics.readonly'),
                  
                      file_get_contents(PATH_TO_PRIVATE_KEY_FILE)  // keyfile you downloaded
                  
                  ));
                  
                  // other settings
                  $client->setClientId(CLIENT_ID);           // from API console
                  $client->setAccessType('offline_access');  // this may be unnecessary?
                  
                  // create service and get data
                  $service = new Google_Service_Analytics($client);
                  $service->data_ga->get($ids, $startDate, $endDate, $metrics, $optParams);
                  

                4.  

                  下面的原始解決方法

                  似乎,盡管文檔含糊不清,大多數 Google API 都可以尚不支持服務帳戶,包括 Google Analytics.他們無法消化 .p12 簽名的 JWT 請求返回的 OAuth2 令牌.所以,就目前而言,您不能將 Google Analytics API V3 與服務帳號.

                  It seems that, despite ambiguous documentation, most Google APIs do not support service accounts yet, including Google Analytics. They cannot digest OAuth2 tokens returned by a .p12 signed JWT request. So, as of right now, you cannot use Google Analytics API V3 with a service account.

                  解決方法:

                  1. 在 Google API 控制臺中,創建一個 客戶端應用程序.

                  1. In the Google API console, create a client application.

                  按照 Google PHP Client API 示例中的步驟生成client_auth_url 使用您的 client_idclient_secret、和 redirect_uri

                  Follow the steps in the Google PHP Client API examples to generate a client_auth_url using your client_id, client_secret, and redirect_uri

                  使用 cURL 登錄 Google.(一定要使用cookie文件!)

                  Login to Google using cURL. (Be sure to use a cookie file!)

                  在 cURL 中打開 client_auth_url 并完成表單.確保你設置了 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);curl_setopt($ch, CURLOPT_HEADER, 1); 作為authorization_code將位于響應的 Location: 標頭中.

                  Open the client_auth_url in cURL and complete the form. Make sure you set curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); and curl_setopt($ch, CURLOPT_HEADER, 1); as the authorization_code will be in the Location: header of the response.

                  使用您的 client_idclient_secretredirect_uri 和第 4 步中的激活碼,向 Google 的 OAuth2令牌機.確保包含 grant_type =authorization_code" 在您的帖子字段中.

                  Using your client_id, client_secret, redirect_uri, and the activation code from Step 4, post a request to the Google's OAuth2 Token machine. Make sure you include grant_type = "authorization_code" in your post fields.

                  萬歲,您現在擁有一個永不過期的 refresh_token 和一個有效的 access_token!向 Google 的 OAuth2 令牌發布請求機器和你的client_idclient_secretredirect_uri,和 refresh_token 當您的 access_token 到期時,您將獲得新的.

                  Hurray, you now have a refresh_token that never expires, and a working access_token! Post a request to the Google's OAuth2 Token machine with your client_id, client_secret, redirect_uri, and refresh_token when your access_token expires and you'll get a new one.

                  這篇關于服務應用程序和 Google Analytics API V3:服務器到服務器 OAuth2 身份驗證?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)

                  <small id='renD1'></small><noframes id='renD1'>

                  <tfoot id='renD1'></tfoot>
                  <i id='renD1'><tr id='renD1'><dt id='renD1'><q id='renD1'><span id='renD1'><b id='renD1'><form id='renD1'><ins id='renD1'></ins><ul id='renD1'></ul><sub id='renD1'></sub></form><legend id='renD1'></legend><bdo id='renD1'><pre id='renD1'><center id='renD1'></center></pre></bdo></b><th id='renD1'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='renD1'><tfoot id='renD1'></tfoot><dl id='renD1'><fieldset id='renD1'></fieldset></dl></div>
                      <bdo id='renD1'></bdo><ul id='renD1'></ul>

                            <tbody id='renD1'></tbody>

                            <legend id='renD1'><style id='renD1'><dir id='renD1'><q id='renD1'></q></dir></style></legend>
                          1. 主站蜘蛛池模板: 午夜寂寞福利视频 | 三区在线 | 一区二区在线不卡 | 免费观看羞羞视频网站 | 国产成人一区二区三区 | av香港经典三级级 在线 | 91文字幕巨乱亚洲香蕉 | 亚洲视频在线一区 | 天天亚洲 | 精品久久久久久久久久 | 国产精品毛片久久久久久 | 日韩电影中文字幕 | 在线观看国产 | 国产成人一区二区三区 | 亚洲色图图片 | 日日摸夜夜添夜夜添特色大片 | 亚洲视频一区在线观看 | 亚洲综合久久精品 | 久热中文字幕 | 成人做爰www免费看视频网站 | 精品综合久久久 | a级免费视频 | 久热国产在线 | 亚洲国产成人精品久久久国产成人一区 | 国产小视频精品 | 国产成人精品免费视频大全最热 | 毛色毛片免费看 | 在线欧美激情 | 亚洲在线一区二区三区 | www.色综合 | 国产精品久久久久久久久免费相片 | 国产7777| 国产激情片在线观看 | 亚洲激情av | 国产精品国产亚洲精品看不卡15 | 亚洲一区二区视频 | 欧美精品一区二区三区一线天视频 | 中文字幕亚洲无线 | 国产精品久久久久久久久久久久冷 | 精品一区二区三区在线观看 | 久久久久亚洲 |