久久久久久久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# 桌面應(yīng)用程序.如何將文件上傳到 Google Drive 的

        C# Desktop application. Simple example how to upload a file to Google Drive(C# 桌面應(yīng)用程序.如何將文件上傳到 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# 桌面應(yīng)用程序.如何將文件上傳到 Google Drive 的簡單示例的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  是否有桌面應(yīng)用程序如何授權(quán) Google Drive 服務(wù)和上傳文件的代碼示例?

                  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
                  

                  但是接下來的步驟是什么?正如我從示例中看到的那樣,我應(yīng)該獲取 IAuthenticator 實例并將其傳遞給 DriveService 類的構(gòu)造函數(shù)......如何獲取 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);
                          }
                      }
                  }
                  

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

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

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

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

                  相關(guān)文檔推薦

                  Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                  XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                  Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標(biāo)簽的 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>
                            主站蜘蛛池模板: 欧美一区二区三区四区在线 | 日韩中文字幕区 | 人妖av| 久久久99精品免费观看 | 亚洲欧美激情精品一区二区 | 亚洲欧美日韩精品 | 欧美一区二区三区在线观看 | 久久国产精品免费视频 | 91av在线免费看 | 亚洲欧美中文日韩在线v日本 | 国产精品成人在线播放 | 亚洲精品在线视频 | 欧美美女爱爱 | 亚洲视频三区 | 国产精品夜夜夜一区二区三区尤 | 国产亚洲精品美女久久久久久久久久 | 欧美区日韩区 | 五月综合激情在线 | 久久久久久久久久久久久久国产 | 国产日韩精品在线 | 中国一级毛片免费 | 99热国产在线播放 | 日韩电影一区二区三区 | 欧美高清hd| 嫩草黄色影院 | 国产精品一区二区三区四区 | 日韩中文一区二区 | 久久综合伊人一区二区三 | 欧美亚洲国产精品 | 成人精品国产一区二区4080 | 自拍偷拍小视频 | 欧美日韩亚洲系列 | 久草福利 | 成人综合视频在线观看 | 久久国产欧美日韩精品 | www.欧美.com | 亚洲天堂成人在线视频 | 蜜桃视频一区二区三区 | 国产视频一区二区 | 夜夜摸天天操 | 国产激情福利 |