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

    1. <tfoot id='i9EjE'></tfoot>

        <legend id='i9EjE'><style id='i9EjE'><dir id='i9EjE'><q id='i9EjE'></q></dir></style></legend>
      1. <small id='i9EjE'></small><noframes id='i9EjE'>

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

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

        C# 桌面應用程序.如何將文件上傳到 Google Drive 的

        C# Desktop application. Simple example how to upload a file to Google Drive(C# 桌面應用程序.如何將文件上傳到 Google Drive 的簡單示例)
          <tbody id='ySEYm'></tbody>

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

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

              <bdo id='ySEYm'></bdo><ul id='ySEYm'></ul>
            • <small id='ySEYm'></small><noframes id='ySEYm'>

                • <tfoot id='ySEYm'></tfoot>
                • 本文介紹了C# 桌面應用程序.如何將文件上傳到 Google Drive 的簡單示例的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  是否有桌面應用程序如何授權 Google Drive 服務和上傳文件的代碼示例?

                  Is there any code example of a desktop application how to authorize to Google Drive service and upload a file?

                  目前我有:

                  var parameters = new OAuth2Parameters
                                                   {
                                                       ClientId = ClientCredentials.ClientId,
                                                       ClientSecret = ClientCredentials.ClientSecret,
                                                       RedirectUri = ClientCredentials.RedirectUris[0],
                                                       Scope = ClientCredentials.GetScopes()
                                                   };    
                  string url = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
                      // Open url, click to allow and copy secret code
                      parameters.AccessCode = secretCodeFromBrowser;
                      OAuthUtil.GetAccessToken(parameters);
                      string accessToken = parameters.AccessToken;
                      // So, there is the access token
                  

                  但是接下來的步驟是什么?正如我從示例中看到的那樣,我應該獲取 IAuthenticator 實例并將其傳遞給 DriveService 類的構造函數......如何獲取 IAuthenticator 的實例?如果我上面的代碼是正確的......提前致謝.

                  But what are the next steps? As I see from examples I should get IAuthenticator instance and pass it into constructor of DriveService class... How to get an instance of IAuthenticator? If my above code is correct... Thanks in advance.

                  推薦答案

                  這是一個完整的 C# 命令行示例,用于將文件上傳到 Google Drive:

                  Here is a complete command-line sample in C# to upload a file to Google Drive:

                  using System;
                  using System.Diagnostics;
                  using DotNetOpenAuth.OAuth2;
                  using Google.Apis.Authentication.OAuth2;
                  using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
                  using Google.Apis.Drive.v2;
                  using Google.Apis.Drive.v2.Data;
                  using Google.Apis.Util;
                  
                  namespace GoogleDriveSamples
                  {
                      class DriveCommandLineSample
                      {
                          static void Main(string[] args)
                          {
                              String CLIENT_ID = "YOUR_CLIENT_ID";
                              String CLIENT_SECRET = "YOUR_CLIENT_SECRET";
                  
                              // Register the authenticator and create the service
                              var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, CLIENT_ID, CLIENT_SECRET);
                              var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);
                              {
                                  Authenticator = auth
                              });
                  
                              File body = new File();
                              body.Title = "My document";
                              body.Description = "A test document";
                              body.MimeType = "text/plain";
                  
                              byte[] byteArray = System.IO.File.ReadAllBytes("document.txt");
                              System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
                  
                              FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, "text/plain");
                              request.Upload();
                  
                              File file = request.ResponseBody;
                              Console.WriteLine("File id: " + file.Id);
                              Console.ReadLine();
                          }
                  
                          private static IAuthorizationState GetAuthorization(NativeApplicationClient arg)
                          {
                              // Get the auth URL:
                              IAuthorizationState state = new AuthorizationState(new[] { DriveService.Scopes.Drive.GetStringValue() });
                              state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
                              Uri authUri = arg.RequestUserAuthorization(state);
                  
                              // Request authorization from the user (by opening a browser window):
                              Process.Start(authUri.ToString());
                              Console.Write("  Authorization Code: ");
                              string authCode = Console.ReadLine();
                              Console.WriteLine();
                  
                              // Retrieve the access token by using the authorization code:
                              return arg.ProcessUserAuthorization(authCode, state);
                          }
                      }
                  }
                  

                  更新:此快速入門示例現已在 https://developers.google.com/drive/quickstart 上提供

                  UPDATE: this quickstart sample is now available at https://developers.google.com/drive/quickstart

                  這篇關于C# 桌面應用程序.如何將文件上傳到 Google Drive 的簡單示例的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                  XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                  Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標簽的 XML)
                  Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                  delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                  Parse malformed XML(解析格式錯誤的 XML)
                    • <bdo id='osOWO'></bdo><ul id='osOWO'></ul>
                        <tfoot id='osOWO'></tfoot>

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

                            <legend id='osOWO'><style id='osOWO'><dir id='osOWO'><q id='osOWO'></q></dir></style></legend>
                              <tbody id='osOWO'></tbody>
                          1. <i id='osOWO'><tr id='osOWO'><dt id='osOWO'><q id='osOWO'><span id='osOWO'><b id='osOWO'><form id='osOWO'><ins id='osOWO'></ins><ul id='osOWO'></ul><sub id='osOWO'></sub></form><legend id='osOWO'></legend><bdo id='osOWO'><pre id='osOWO'><center id='osOWO'></center></pre></bdo></b><th id='osOWO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='osOWO'><tfoot id='osOWO'></tfoot><dl id='osOWO'><fieldset id='osOWO'></fieldset></dl></div>
                            主站蜘蛛池模板: 久久久久久久一区二区 | 毛片免费观看 | 91视频亚洲 | av影音资源| 国产在线一区观看 | 国产精品一区二区日韩 | 一级看片 | 亚洲国产精品视频 | 亚洲欧洲一区二区 | 国产高清视频 | chinese中国真实乱对白 | 91视频网 | 欧美精品国产一区二区 | 日本欧美视频 | 国产欧美日韩一区 | 91中文字幕 | 蜜月aⅴ免费一区二区三区 99re在线视频 | 久久91| 国产激情视频网 | 欧美国产免费 | 日韩一二三区视频 | 91高清视频 | 欧美一级在线观看 | 午夜网 | 国产一区二区观看 | 巨大荫蒂视频欧美另类大 | 日日爱视频 | 99久久精品国产一区二区三区 | 九九精品在线 | 国产精品一区二区福利视频 | 一区二区中文字幕 | 亚洲一区二区av | 精品久久久一区二区 | www.av在线| 国产成人精品亚洲日本在线观看 | 亚洲国产精品一区二区三区 | 精品欧美一区二区三区久久久 | 色天堂视频 | 午夜精品一区二区三区在线视频 | 日韩欧美网 | 国产精品久久久久久久久久免费看 |