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

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

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

      • <bdo id='qCFyX'></bdo><ul id='qCFyX'></ul>
      <legend id='qCFyX'><style id='qCFyX'><dir id='qCFyX'><q id='qCFyX'></q></dir></style></legend>
    1. 如何通過 .NET 中的 Google Drive SDK 使用刷新令牌生

      How to generate access token using refresh token through Google Drive SDK in .NET?(如何通過 .NET 中的 Google Drive SDK 使用刷新令牌生成訪問令牌?)
      <i id='yPbQV'><tr id='yPbQV'><dt id='yPbQV'><q id='yPbQV'><span id='yPbQV'><b id='yPbQV'><form id='yPbQV'><ins id='yPbQV'></ins><ul id='yPbQV'></ul><sub id='yPbQV'></sub></form><legend id='yPbQV'></legend><bdo id='yPbQV'><pre id='yPbQV'><center id='yPbQV'></center></pre></bdo></b><th id='yPbQV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yPbQV'><tfoot id='yPbQV'></tfoot><dl id='yPbQV'><fieldset id='yPbQV'></fieldset></dl></div>
        <bdo id='yPbQV'></bdo><ul id='yPbQV'></ul>

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

            <tbody id='yPbQV'></tbody>

          <tfoot id='yPbQV'></tfoot>

            <legend id='yPbQV'><style id='yPbQV'><dir id='yPbQV'><q id='yPbQV'></q></dir></style></legend>
              1. 本文介紹了如何通過 .NET 中的 Google Drive SDK 使用刷新令牌生成訪問令牌?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有一個使用 Google Drive 訪問用戶文件的 .NET 應用程序.我能夠獲得授權碼,并且我已經能夠通過 AccessToken 和 RefreshToken 交換授權碼.問題是我無法刷新訪問令牌,并且它會在一小時后過期.

                I have a .NET application that is using Google Drive to access the user's file. I am able to get the authorization code, and I have been able to exchange the authorization code by the AccessToken and the RefreshToken. The issue is that I cannot refresh the access token, and it expires after an hour.

                類似于這個問題:如何通過 google drive API 使用刷新令牌生成訪問令牌? 除了我在 .NET 中工作(使用 Google.API... DLL).

                Similar to this question: How to generate access token using refresh token through google drive API? except that I am working in .NET (using the Google.APIs... DLLs).

                我知道這一點:https://developers.google.com/accounts/docs/OAuth2InstalledApp#refresh 但是,我期望 IAuthorizationState 或 OAuth2Authenticator 對象中提供某種方法來允許我刷新訪問令牌.

                I am aware of this: https://developers.google.com/accounts/docs/OAuth2InstalledApp#refresh however, I am expecting some sort of method available in the IAuthorizationState or OAuth2Authenticator object to allow me refresh the access token.

                請指教.謝謝.

                請注意,使用此代碼我可以獲得訪問令牌.只是我希望這段代碼在 Google API 中.

                Please note that using this code I am able to get the Access Token. It is just that I am expecting this code to be inside the Google API.

                    public class OAuth2AccessTokenReponse
                    {
                        public string access_token;
                        public int expires_in;
                        public string token_type; 
                    }
                    public static string refreshAccessToken()
                    {
                        using (System.Net.WebClient client = new System.Net.WebClient())
                        {
                            byte[] response = client.UploadValues("https://accounts.google.com/o/oauth2/token", new System.Collections.Specialized.NameValueCollection(){
                                {"client_id", ClientID},
                                {"client_secret", ClientSecret},
                                {"refresh_token", "XXXXX"},
                                {"grant_type", "refresh_token"}
                            });
                            string sresponse = System.Text.Encoding.Default.GetString(response);
                            OAuth2AccessTokenReponse o = (OAuth2AccessTokenReponse) Newtonsoft.Json.JsonConvert.DeserializeObject(sresponse, typeof(OAuth2AccessTokenReponse));
                            return o.access_token;        
                        }
                    }
                

                推薦答案

                我研究了一個更合適的示例:GoogleApisSample 的 Tasks.WinForms.NoteMgr... 并找到了解決方案.

                I studied a more suitable sample: the Tasks.WinForms.NoteMgr of the GoogleApisSample... and with it I found the solution.

                解決方案在下面的代碼中.它的關鍵部分是調用 arg.RefreshToken(state);

                The solution is in the code below. The key part of it is calling arg.RefreshToken(state);

                謝謝.

                    public static Authentication.IAuthenticator UseSavedAuthorization()
                    {          
                
                        var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
                        provider.ClientIdentifier = ClientID;
                        provider.ClientSecret = ClientSecret;
                
                        OAuth2Authenticator<NativeApplicationClient> auth = new OAuth2Authenticator<NativeApplicationClient>(provider, getState);
                
                        auth.LoadAccessToken();
                
                        return auth;             
                    }
                
                
                public static IAuthorizationState getState(NativeApplicationClient arg)
                    {
                        IAuthorizationState state = new AuthorizationState(new[] { TasksService.Scopes.Tasks.GetStringValue(), 
                                DriveService.Scopes.DriveFile.GetStringValue() , DriveService.Scopes.Drive.GetStringValue()
                        });
                        state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
                
                        state.RefreshToken = "<refresh token previously saved>";        
                        arg.RefreshToken(state); 
                
                        return state; 
                    }`
                

                這篇關于如何通過 .NET 中的 Google Drive SDK 使用刷新令牌生成訪問令牌?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                extracting just page text using HTMLAgilityPack(使用 HTMLAgilityPack 僅提取頁面文本)
                Using C#, how can we pull attribute values from an XML Schema file and output that onto a CSV file?(使用 C#,我們如何從 XML Schema 文件中提取屬性值并將其輸出到 CSV 文件中?)
                Parse XML with LINQ to get child elements(使用 LINQ 解析 XML 以獲取子元素)

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

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

                      1. <tfoot id='yXqRP'></tfoot>
                          主站蜘蛛池模板: 国产精品久久久久久久模特 | 超碰在线久 | 久久久.com| 天天综合网天天综合 | 国产精品视频一二三区 | 国产小视频在线 | 91麻豆久久久 | 久久这里只有精品首页 | 午夜国产一级片 | 国产成人免费在线 | 日韩精品免费一区 | 国精品一区 | 亚洲国产精品久久久久 | 九九九久久国产免费 | 在线免费观看日本视频 | 天堂av中文 | 国产亚洲欧美在线 | 国产7777 | 日韩欧美一级片 | 色资源站 | 亚洲免费精品一区 | 天天躁日日躁狠狠躁2018小说 | 日韩不卡三区 | 99re热精品视频 | 欧美久久免费观看 | 久久精品视频99 | 国产精品久久久久久久午夜 | 免费精品视频 | 亚洲高清网 | 成人99| 国产97久久 | 亚洲视频免费在线观看 | 日韩二区三区 | 精品在线一区二区三区 | 久久一 | 亚洲欧美日韩国产综合 | 亚洲精品乱码久久久久久蜜桃91 | 久草www| 亚洲精品久 | 日韩欧美在线播放 | 日韩精品一区二区三区免费观看 |