1. <small id='bo9FN'></small><noframes id='bo9FN'>

        <bdo id='bo9FN'></bdo><ul id='bo9FN'></ul>
      <legend id='bo9FN'><style id='bo9FN'><dir id='bo9FN'><q id='bo9FN'></q></dir></style></legend>

      <tfoot id='bo9FN'></tfoot>

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

        .NET Google api 1.7 beta 使用刷新令牌进行身份验证

        时间:2023-08-28

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

            • <bdo id='YbuHe'></bdo><ul id='YbuHe'></ul>

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

              <tfoot id='YbuHe'></tfoot>
            • <legend id='YbuHe'><style id='YbuHe'><dir id='YbuHe'><q id='YbuHe'></q></dir></style></legend>
                  <tbody id='YbuHe'></tbody>
                  本文介绍了.NET Google api 1.7 beta 使用刷新令牌进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我一直在查看 Oauth .Net Google API,以便通过 OAuth 进行身份验证并使用 Google drive API.

                  I've been looking at the Oauth .Net Google Apis in order to authenticate via OAuth and use the Google drive Apis.

                  具体来说,我想使用我已经存储的刷新令牌来实例化 GoogleDrive 服务.

                  Specifically, I want to use a refresh token I already have stored in order to use it to instantiate a GoogleDrive service.

                  我找到了类似的样本https:///code.google.com/p/google-api-dotnet-client/source/browse/Tasks.SimpleOAuth2/Program.cs?repo=samples

                  这似乎使用GoogleWebAuthorizationBroker.AuthorizeAsync",但我不确定如何使用刷新令牌而不是您在本示例中提供的客户端机密来使用该方法.

                  That seem to use "GoogleWebAuthorizationBroker.AuthorizeAsync" but I'm not sure how I can use that method with a refresh token rather than the client secrets you seem to be feeding it in this example.

                  推荐答案

                  如果我理解正确,您是在问如何根据现有的刷新令牌创建新的 Google 服务.

                  If I understand you correctly, you are asking how can you create a new Google service, based on an existing refresh token.

                  因此,您可以执行以下操作:

                  So, you can do the following:

                  var token = new TokenResponse { RefreshToken = "YOUR_REFRESH_TOKEN_HERE" }; 
                  var credentials = new UserCredential(new GoogleAuthorizationCodeFlow(
                      new GoogleAuthorizationCodeFlow.Initializer 
                      {
                        ClientSecrets = [your_client_secrets_here]
                      }), "user", token);
                  

                  然后您可以将您的凭据传递给服务的初始化程序.

                  Then you can pass your credentials to the service's initializer.

                  通过执行上述操作,GoogleAuthorizationCodeFlow 将根据您刷新令牌和客户端机密获取新的访问令牌.

                  By doing the above, GoogleAuthorizationCodeFlow will get a new access token based on you refresh token and client secrets.

                  请注意,您必须在此处拥有客户端密码,否则您将无法获得访问令牌.

                  Note that you must have client secrets here, without that, you won't be able to get an access token.

                  这篇关于.NET Google api 1.7 beta 使用刷新令牌进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何通过 Google Drive .NET API v3 使用服务帐户访问 下一篇:为什么我得到 System.UnauthorizedAccessException 对路径

                  相关文章

                  最新文章

                  <i id='ZoRhx'><tr id='ZoRhx'><dt id='ZoRhx'><q id='ZoRhx'><span id='ZoRhx'><b id='ZoRhx'><form id='ZoRhx'><ins id='ZoRhx'></ins><ul id='ZoRhx'></ul><sub id='ZoRhx'></sub></form><legend id='ZoRhx'></legend><bdo id='ZoRhx'><pre id='ZoRhx'><center id='ZoRhx'></center></pre></bdo></b><th id='ZoRhx'></th></span></q></dt></tr></i><div id='ZoRhx'><tfoot id='ZoRhx'></tfoot><dl id='ZoRhx'><fieldset id='ZoRhx'></fieldset></dl></div>
                1. <legend id='ZoRhx'><style id='ZoRhx'><dir id='ZoRhx'><q id='ZoRhx'></q></dir></style></legend>

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

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