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

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

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

    <legend id='zMq14'><style id='zMq14'><dir id='zMq14'><q id='zMq14'></q></dir></style></legend>
    • <bdo id='zMq14'></bdo><ul id='zMq14'></ul>
    1. <tfoot id='zMq14'></tfoot>

        Google OAuth2 服務(wù)帳戶訪問令牌請求給出“無效請求

        Google OAuth2 Service Account Access Token Request gives #39;Invalid Request#39; Response(Google OAuth2 服務(wù)帳戶訪問令牌請求給出“無效請求響應(yīng))

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

        <legend id='qWyxS'><style id='qWyxS'><dir id='qWyxS'><q id='qWyxS'></q></dir></style></legend>

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

                    <tbody id='qWyxS'></tbody>
                • 本文介紹了Google OAuth2 服務(wù)帳戶訪問令牌請求給出“無效請求"響應(yīng)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在嘗試通過服務(wù)器到服務(wù)器方法與我的應(yīng)用啟用的 BigQuery API 進(jìn)行通信.

                  I'm trying to communicate with my app's enabled BigQuery API via the server to server method.

                  我已勾選此 Google 指南上的所有方框,以構(gòu)建我的 JWT盡我所能在 C# 中.

                  I've ticked all the boxes on this Google guide for constructing my JWT as best I can in C#.

                  我已經(jīng)對所有必要的東西都進(jìn)行了 Base64Url 編碼.

                  And I've Base64Url encoded everything that was necessary.

                  但是,我從 google 得到的唯一響應(yīng)是 400 Bad Request

                  However, the only response I get from google is a 400 Bad Request

                  "error" : "invalid_request"
                  

                  我已經(jīng)從這些其他 SO 問題中確定了以下所有內(nèi)容:

                  I've made sure of all of the following from these other SO questions:

                  • 簽名正確加密使用 RSA 和 SHA256
                  • 我正在使用 POST 并使用 application/x-www-form-urlencoded 內(nèi)容類型
                  • 轉(zhuǎn)義了聲明集中的所有反斜杠
                  • 在 POST 數(shù)據(jù)中嘗試了各種 grant_type 和斷言值

                  當(dāng)我使用 Fiddler 時,我得到了相同的結(jié)果.該錯誤消息令人沮喪地缺乏詳細(xì)信息!我還能嘗試什么?!這是我的代碼:

                  I get the same result when I use Fiddler. The error message is frustratingly lacking in detail! What else can I try?! Here's my code:

                  class Program
                  {
                      static void Main(string[] args)
                      {
                          // certificate
                          var certificate = new X509Certificate2(@"<Path to my certificate>.p12", "notasecret");
                  
                          // header
                          var header = new { typ = "JWT", alg = "RS256" };
                  
                          // claimset
                          var times = GetExpiryAndIssueDate();
                          var claimset = new
                          {
                              iss = "<email address of the client id of my app>",
                              scope = "https://www.googleapis.com/auth/bigquery",
                              aud = "https://accounts.google.com/o/oauth2/token",
                              iat = times[0],
                              exp = times[1],
                          };
                  
                          // encoded header
                          var headerSerialized = JsonConvert.SerializeObject(header);
                          var headerBytes = Encoding.UTF8.GetBytes(headerSerialized);
                          var headerEncoded = Base64UrlEncode(headerBytes);
                  
                          // encoded claimset
                          var claimsetSerialized = JsonConvert.SerializeObject(claimset);
                          var claimsetBytes = Encoding.UTF8.GetBytes(claimsetSerialized);
                          var claimsetEncoded = Base64UrlEncode(claimsetBytes);
                  
                          // input
                          var input = headerEncoded + "." + claimsetEncoded;
                          var inputBytes = Encoding.UTF8.GetBytes(input);
                  
                          // signiture
                          var rsa = certificate.PrivateKey as RSACryptoServiceProvider;
                          var cspParam = new CspParameters
                          {
                              KeyContainerName = rsa.CspKeyContainerInfo.KeyContainerName,
                              KeyNumber = rsa.CspKeyContainerInfo.KeyNumber == KeyNumber.Exchange ? 1 : 2
                          };
                          var aescsp = new RSACryptoServiceProvider(cspParam) { PersistKeyInCsp = false };
                          var signatureBytes = aescsp.SignData(inputBytes, "SHA256");
                          var signatureEncoded = Base64UrlEncode(signatureBytes);
                  
                          // jwt
                          var jwt = headerEncoded + "." + claimsetEncoded + "." + signatureEncoded;
                  
                          Console.WriteLine(jwt);
                  
                          var client = new HttpClient();
                          var uri = "https://accounts.google.com/o/oauth2/token";
                          var post = new Dictionary<string, string>
                          {
                              {"assertion", jwt},
                              {"grant_type", "urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer"}
                          };
                          var content = new FormUrlEncodedContent(post);
                          var result = client.PostAsync(uri, content).Result;
                  
                          Console.WriteLine(result);
                          Console.WriteLine(result.Content.ReadAsStringAsync().Result);
                          Console.ReadLine();
                      }
                  
                      private static int[] GetExpiryAndIssueDate()
                      {
                          var utc0 = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                          var issueTime = DateTime.Now;
                  
                          var iat = (int)issueTime.Subtract(utc0).TotalSeconds;
                          var exp = (int)issueTime.AddMinutes(55).Subtract(utc0).TotalSeconds;
                  
                          return new[]{iat, exp};
                      }
                  
                      private static string Base64UrlEncode(byte[] input)
                      {
                          var output = Convert.ToBase64String(input);
                          output = output.Split('=')[0]; // Remove any trailing '='s
                          output = output.Replace('+', '-'); // 62nd char of encoding
                          output = output.Replace('/', '_'); // 63rd char of encoding
                          return output;
                      }
                  }
                  

                  推薦答案

                  看來我在上面評論中的猜測是正確的.我通過更改使您的代碼正常工作:

                  Looks like my guess in the comment above was correct. I got your code working by changing:

                  "urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer"

                  到:

                  "urn:ietf:params:oauth:grant-type:jwt-bearer"

                  看起來你不小心對它進(jìn)行了雙重編碼.

                  Looks like you were accidentally double-encoding it.

                  我現(xiàn)在收到的回復(fù)類似于:

                  I now get a response which looks something like:

                  {
                    "access_token" : "1/_5pUwJZs9a545HSeXXXXXuNGITp1XtHhZXXxxyyaacqkbc",
                    "token_type" : "Bearer",
                    "expires_in" : 3600
                  }
                  

                  編輯說明:請確保您的服務(wù)器上的日期/時間/時區(qū)/夏令時配置正確.將時鐘延遲幾秒鐘也會導(dǎo)致 invalid_grant 錯誤.http://www.time.gov 將提供美國政府的官方時間,包括 UTC.

                  Edited Note: please make sure to have the correct date/time/timezone/dst configuration on your server. Having the clock off by even a few seconds will result in an invalid_grant error. http://www.time.gov will give the official time from the US govt, including in UTC.

                  這篇關(guān)于Google OAuth2 服務(wù)帳戶訪問令牌請求給出“無效請求"響應(yīng)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運(yùn)行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                  Calling A Button OnClick from a function(從函數(shù)調(diào)用按鈕 OnClick)
                  • <legend id='xM19i'><style id='xM19i'><dir id='xM19i'><q id='xM19i'></q></dir></style></legend>
                      <tbody id='xM19i'></tbody>
                      <bdo id='xM19i'></bdo><ul id='xM19i'></ul>

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

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

                            主站蜘蛛池模板: 精品在线一区二区 | 亚洲国产成人精品女人 | 国产精品一区一区三区 | 国产精品久久久久久久7777 | 国产一区久久久 | 99热这里只有精品8 激情毛片 | 成人午夜看片 | 精品国产伦一区二区三区观看说明 | 欧美午夜激情在线 | 欧美黄色一级毛片 | 国产精品久久久久久久免费大片 | 日本午夜在线视频 | 久久精品日产第一区二区三区 | 国产99久久久国产精品 | 男人av在线播放 | 国产日韩一区二区三免费高清 | 国产三区精品 | 欧美精品一二三区 | 999国产精品视频免费 | 亚洲精品久久久久久久久久久 | 91电影院| 日韩欧美福利视频 | 午夜在线视频 | 欧美亚州 | 久久久一区二区 | 鲁大师一区影视 | 天天操狠狠操 | 亚洲国产aⅴ精品一区二区 免费观看av | 婷婷在线视频 | 激情视频中文字幕 | 久久久久久中文字幕 | 国产av毛片| a在线视频 | 久久99蜜桃综合影院免费观看 | 成人精品国产一区二区4080 | 婷婷久久五月 | 一区二区三区在线看 | 99pao成人国产永久免费视频 | 成年女人免费v片 | 亚洲精选一区 | 欧美区在线 |