Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 516
Owen Avatar asked Sep 28 '22 00:09

Owen


1 Answers

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.

like image 133
Owen Avatar answered Nov 15 '22 06:11

Owen