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

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

    <bdo id='fveAh'></bdo><ul id='fveAh'></ul>

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

    <legend id='fveAh'><style id='fveAh'><dir id='fveAh'><q id='fveAh'></q></dir></style></legend>
      <tfoot id='fveAh'></tfoot>

        php 中使用 curl 的 OAuth 2.0

        OAuth 2.0 in php using curl(php 中使用 curl 的 OAuth 2.0)
            <i id='SbPtT'><tr id='SbPtT'><dt id='SbPtT'><q id='SbPtT'><span id='SbPtT'><b id='SbPtT'><form id='SbPtT'><ins id='SbPtT'></ins><ul id='SbPtT'></ul><sub id='SbPtT'></sub></form><legend id='SbPtT'></legend><bdo id='SbPtT'><pre id='SbPtT'><center id='SbPtT'></center></pre></bdo></b><th id='SbPtT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='SbPtT'><tfoot id='SbPtT'></tfoot><dl id='SbPtT'><fieldset id='SbPtT'></fieldset></dl></div>
              <tbody id='SbPtT'></tbody>

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

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

                  <legend id='SbPtT'><style id='SbPtT'><dir id='SbPtT'><q id='SbPtT'></q></dir></style></legend>
                  本文介紹了php 中使用 curl 的 OAuth 2.0的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我需要獲取用于 OAuth 2.0 的 access_token 和 refresh_token 才能訪問 Google API,下面的 php 腳本應(yīng)該返回一個帶有 access_token、refresh_token 的 json,如下所示:

                  I need to get my access_token and refresh_token for OAuth 2.0 to Access Google APIs, the php script below should return a json with access_token, refresh_token like this:

                  {
                    "access_token" : "####",
                    "token_type" : "Bearer",
                    "expires_in" : 3600,
                    "refresh_token" : "####"
                  }
                  

                  但是,php 腳本只返回這個錯誤信息:

                  but, the php script return me only this error message:

                  {
                  "error" : "invalid_request",
                  "error_description" : "Client must specify either client_id or client_assertion, not both"
                  }
                  

                  我嘗試刪除 client_secret/client_id 并僅使用 client_id/client_secret,但仍然出現(xiàn)相同的錯誤.

                  I tried to remove client_secret/client_id and use only client_id/client_secret, but still get the same error.

                  $client_id = '###.apps.googleusercontent.com';
                  $redirect_uri = 'http://localhost/phpConnectToDB/csv/refreshFusionTable.php';
                  $client_secret = '###';
                  
                  $ch = curl_init();
                  
                  curl_setopt($ch, CURLOPT_URL, "https://accounts.google.com/o/oauth2/token");
                  
                  $code = $_REQUEST['code'];
                  
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
                  
                  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                  
                  
                  curl_setopt($ch, CURLOPT_POSTFIELDS, array(
                  'code' => $code,
                  'client_id' => $clientID,
                  'client_secret' => $clientSecret,
                  'redirect_uri' => $redirect_uri,
                  'grant_type' => 'authorization_code'
                  ));
                  
                  $data = curl_exec($ch);
                  
                  var_dump($data);
                  

                  盡管 cmd 中的 curl 可以正常工作并返回我的訪問權(quán)限和刷新令牌而沒有任何錯誤.

                  Although curl in cmd works and returns me access and refresh token without any errors.

                  curl --data "code=###&client_id=###.apps.googleusercontent.com&client_secret=###&redirect_uri=http://localhost/phpConnectToDB/csv/refreshFusionTable.php&grant_type=authorization_code" https://accounts.google.com/o/oauth2/token
                  

                  我不明白為什么會出現(xiàn)缺少的方案錯誤,盡管 .php 腳本存在并且它位于給定的路徑上.你能幫我嗎?

                  I don't understand why I get the missing scheme error, although the .php script exists and it's located on the given path. Could you help me please ?

                  EDIT

                  解決了redirect_uri 的參數(shù)值無效:缺少方案"的問題,我只是用這個 'redirect_uri' => $redirect_uri 替換了 'redirect_uri' => urlencode($redirect_uri),在CURLOPT_POSTFIELDS.

                  EDIT

                  Problem with "Invalid parameter value for redirect_uri: Missing scheme" solved, I just replaced 'redirect_uri' => urlencode($redirect_uri), with this 'redirect_uri' => $redirect_uri, in CURLOPT_POSTFIELDS.

                  推薦答案

                  哇,愚蠢的錯誤,我應(yīng)該休息一下.

                  Wow, stupid mistake, I should have a rest.

                  變量名稱不匹配.我定義:

                  The variables names don't match. I defined:

                      $client_id = '###.apps.googleusercontent.com';
                      $client_secret = '###';
                  

                  但是這里我使用了一個不存在的 clientID 和 clientSecret :

                  But here I used an non-existing clientID and clientSecret :

                      curl_setopt($ch, CURLOPT_POSTFIELDS, array(
                      'code' => $code,
                      'client_id' => $clientID,
                      'client_secret' => $clientSecret,
                      'redirect_uri' => $redirect_uri,
                      'grant_type' => 'authorization_code'
                      ));
                  

                  固定和工作的 PHP 腳本

                      $client_id = '###.apps.googleusercontent.com';
                      $redirect_uri = 'http://localhost/phpConnectToDB/csv/refreshFusionTable.php';
                      $client_secret = '###';
                  
                      $ch = curl_init();
                      
                      curl_setopt($ch, CURLOPT_URL, "https://accounts.google.com/o/oauth2/token");
                      
                      curl_setopt($ch, CURLOPT_POST, TRUE);
                      
                      $code = $_REQUEST['code'];
                  
                      // This option is set to TRUE so that the response
                      // doesnot get printed and is stored directly in
                      // the variable
                      curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
                      
                      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                      
                      curl_setopt($ch, CURLOPT_POSTFIELDS, array(
                      'code' => $code,
                      'client_id' => $client_id,
                      'client_secret' => $client_secret,
                      'redirect_uri' => $redirect_uri,
                      'grant_type' => 'authorization_code'
                      ));
                  
                      $data = curl_exec($ch);
                      
                      var_dump($data);
                  

                  但是我不得不說google在這里提供了一個有點(diǎn)誤導(dǎo)性的錯誤信息,因?yàn)槲覜]有定義client_id和client_secret,錯誤信息是:

                  But I have to say that google provides a little misleading error message here, because I hadn't defined client_id nor client_secret and the error message was:

                      {
                      "error" : "invalid_request",
                      "error_description" : "Client must specify either client_id or client_assertion, not both"
                      }
                  

                  這篇關(guān)于php 中使用 curl 的 OAuth 2.0的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標(biāo)不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術(shù)方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動程序)
                  <i id='SJWfR'><tr id='SJWfR'><dt id='SJWfR'><q id='SJWfR'><span id='SJWfR'><b id='SJWfR'><form id='SJWfR'><ins id='SJWfR'></ins><ul id='SJWfR'></ul><sub id='SJWfR'></sub></form><legend id='SJWfR'></legend><bdo id='SJWfR'><pre id='SJWfR'><center id='SJWfR'></center></pre></bdo></b><th id='SJWfR'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='SJWfR'><tfoot id='SJWfR'></tfoot><dl id='SJWfR'><fieldset id='SJWfR'></fieldset></dl></div>

                        • <small id='SJWfR'></small><noframes id='SJWfR'>

                            <tbody id='SJWfR'></tbody>
                          <tfoot id='SJWfR'></tfoot>
                            <bdo id='SJWfR'></bdo><ul id='SJWfR'></ul>

                          • <legend id='SJWfR'><style id='SJWfR'><dir id='SJWfR'><q id='SJWfR'></q></dir></style></legend>
                          • 主站蜘蛛池模板: 欧美中文字幕在线 | 国产一区二区观看 | 欧美一级欧美一级在线播放 | 一a一片一级一片啪啪 | 日韩精品一区二区三区中文在线 | 久久精品免费看 | 欧美精品在线一区 | re久久| 风间由美一区二区三区在线观看 | 国产美女在线免费观看 | 亚洲资源在线 | 免费不卡视频 | 欧美日韩精品久久久免费观看 | 午夜免费精品视频 | 中文字幕在线精品 | 久久久99精品免费观看 | 亚洲精品99久久久久久 | 国产欧美一区二区三区久久手机版 | www.888www看片 | 欧美中文字幕在线 | 嫩草视频在线 | 91免费观看视频 | 另类a v| 精品啪啪| 国产专区在线 | 成人在线免费观看视频 | 成人免费视频在线观看 | 97超碰人人 | 日韩一区二区三区av | 色婷婷一区二区三区四区 | 韩国av影院 | 蜜桃视频一区二区三区 | 人人干人人草 | 中文字幕一区二区三区四区五区 | 综合久 | 欧美性一区二区三区 | 日韩在线| www.成人.com | 日韩中出 | 在线视频国产一区 | 欧美日韩国产精品一区二区 |