Trello.Net authorisation works but can't access data once authorised

£可爱£侵袭症+ 提交于 2019-12-10 13:56:26

问题


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.

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);

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]"

I then authorise using:

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() returns null every time. The same problem with Cards.ForMe() and other methods. Everything is null. Why?

What am I doing wrong?


回答1:


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

Trello.Net

JSON.Net

RestSharp

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

Hope this helps somebody who reads this.




回答2:


Had the same problem, above answer helped me. Though I couldn't get the latest but had to use:

"RestSharp" version="104.1 "Newtonsoft.Json" version="6.0.1"

Since The nuget also doesn't have the correct color enum i had to download the project and make my own changes.



来源:https://stackoverflow.com/questions/30095163/trello-net-authorisation-works-but-cant-access-data-once-authorised

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!