Trello.Net授权有效,但一旦授权就无法访问数据 [英] Trello.Net authorisation works but can't access data once authorised

查看:51
本文介绍了Trello.Net授权有效,但一旦授权就无法访问数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Trello.Net 的新手,并且在授权方面有些挣扎.我了解请求URL,然后要求用户浏览该URL以获得令牌的过程.

I am new to Trello.Net and struggling a little with authorisation. I understand the process, of requesting a URL and then asking the user to browse to that URL to get a token.

第一个问题是我试图编写一个无需任何用户界面即可自动运行的进程.因此,我必须使用一个硬编码的令牌,该令牌是通过运行此代码以获取URL来获取的,然后我可以手动浏览该URL.我宁愿自动执行此部分(以编程方式获取生成的令牌,而不是让用户浏览某个地方):

The first problem is I am trying to write a process which runs automatically without any UI. So I'm having to use a hard coded token, which I obtained by running this code to get a URL, which I then browse to manually. I would rather do this part automatically (get the resulting token programatically, not by having the user browse somewhere):

 ITrello trello = new Trello(Key);
    var url = trello.GetAuthorizationUrl("TrelloCapture", Scope.ReadWrite, Expiration.Never);
    Console.WriteLine(url);

当我浏览该URL时,它会为我显示一个令牌,目前,它已按以下方式硬编码到我的应用程序中:

This URL, when I browse to it, displays for me a token which, for now, I hardcoded into my application as follows:

var token = "[the token copied and pasted from the web page]"

然后我授权使用:

trello.Authorize(token);

似乎工作正常.接下来,我要访问一些基本数据,这是我的第二个问题所在.

Which seems to work fine. Next I want to access some basic data, and this is where my second problem comes in.

// Get the authenticated member
Member me = trello.Members.Me();
Console.WriteLine(me.FullName);

Members.Me()每次返回 null .与 Cards.ForMe()和其他方法相同的问题.一切都是 null .为什么?

Members.Me() returns null every time. The same problem with Cards.ForMe() and other methods. Everything is null. Why?

我在做什么错了?

推荐答案

我找到了答案.我通过在解决方案中获取这些 NuGet 软件包的最新版本来解决此问题:

I found the answer. I fixed it by getting the latest versions of these NuGet packages in my solution:

Trello.Net

JSON.Net

RestSharp

获得这些最新版本后,我在trello对象中看到了正确的值,而不是 null .

After getting those latest versions I was seeing proper values instead of null in the trello objects.

希望这对阅读本文的人有所帮助.

Hope this helps somebody who reads this.

这篇关于Trello.Net授权有效,但一旦授权就无法访问数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆