简体   繁体   English

Dropnet获取访问令牌无法执行0auth的第三步

[英]Dropnet getting access token cant peform 3rd step of 0auth

Hi guys im trying to use dropnet as means to be using dropbox as a cloud storage for my application, and following the 3 step process using the normal 0auth 大家好,我尝试使用dropnet作为将dropbox用作我的应用程序的云存储的方法,并使用正常的0auth遵循以下3个步骤

1.Get Request Token[done] 1.获取请求令牌[完成]

2.Send user for authorization, and get back verifier[done] 2.发送用户授权,然后返回验证程序[完成]

3.Get Access token using the original Request Token and the verifier[issue!] 3.使用原始请求令牌和验证程序获取访问令牌[问题!]

if i understand the api correctly since i want to use a single account for my storage i need api key,api secret,token and secret.the token and secret seems to be accessible from the third steps and its my trouble. 如果我正确地理解了api,因为我想使用一个帐户存储,则需要api密钥,api secret,token和secret.Token和secret似乎可以从第三步访问,这是我的麻烦。

from the second step i get this url 从第二步,我得到这个网址

https://www.dropbox.com/1/oauth/authorize?oauth_token=xxxxxxxxxx https://www.dropbox.com/1/oauth/authorize?oauth_token=xxxxxxxxxx

before pressing authenticate to allow my app to use dropbox 在按身份验证以允许我的应用使用保管箱之前

from the documentation i read that you need to use this method UserLogin GetAccessToken(string code, string redirectUri); 从我阅读的文档中,您需要使用此方法UserLogin GetAccessToken(string code,string redirectUri);

i am assuming here xxxxx is the string code to validate that is the original 我假设这里xxxxx是验证原始的字符串代码

so i made code as follows 所以我做了如下代码

var accessToken = client.GetAccessToken("xxxxxxx","https://www.dropbox.com/1/oauth/authorize?oauth_token=xxxxxxxxxx);
            var ats =accessToken.Secret;
            var att = accessToken.Token;
 Console.Writeline(ats);
Console.Writeline(att):

in hopes of getting the console to print my secret and token for my acct but it dosent work ?Giving me the error of 希望让控制台为我的帐户打印我的秘密和令牌,但确实有用吗?

An unhandled exception of type 'DropNet.Exceptions.DropboxRestException' occurred in DropNet.dll DropNet.dll中发生了类型为'DropNet.Exceptions.DropboxRestException'的未处理异常

help please ! 请帮助 !

Solved the problem myself,here is the full code 我自己解决了问题,这是完整的代码

DropNetClient client = new DropNetClient(variable.ApiKey, variable.ApiSecret);



]
           var response =client.GetToken();
            var t = response.Token;
            var s = response.Secret;
            Console.WriteLine(s);
            Console.WriteLine(t);
            var authorizeUrl = client.BuildAuthorizeUrl(new DropNet.Models.UserLogin
            {
                Secret = s,
                Token = t

            }
                );

            DropNetClient client2= new DropNetClient(variable.ApiKey, variable.ApiSecret,t,s);


            // Prompt for user to auth
            Process.Start(authorizeUrl);
            // PRESS KEY AFTER authorization AFTER
            Console.ReadKey();

          // If the user authed, let's get that token
          try
            {
                var Token = client2.GetAccessToken();
                var userToken = Token.Token;
                var userSecret = Token.Secret;
                Console.WriteLine(userSecret);//ACCESS TOKEN SECRET
                Console.WriteLine(userToken);//ACCESS TOKEN
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception! " + e.Message);
                Console.ReadKey();

            }
            // save for later

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM