Invalid token when using Manatee.Trello

415 views Asked by At

I've been using Manatee.Trello to scan cards on our Trello boards for reporting purposes. However, this morning the scanning code which has worked for weeks stopped working. It appears to be giving an HttpRequestException: 'invalid token'.

Here is a short example which demonstrates the problem, based on the examples in the wiki page Manatee.Trello Usage. It is attempting to access the Trello.com Welcome board.

using System;
using System.Diagnostics;
using Manatee.Trello;
using Manatee.Trello.ManateeJson;
using Manatee.Trello.WebApi;
using Manatee.Trello.Exceptions;

namespace MspUpdate
{
    class Program
    {

        static void Main(string[] args)
        {
            string BrdNm;
            Exception innerException = null;
            TrelloInteractionException te = new TrelloInteractionException(innerException);

            var serializer = new ManateeSerializer();
            TrelloConfiguration.Serializer = serializer;
            TrelloConfiguration.Deserializer = serializer;
            TrelloConfiguration.JsonFactory = new ManateeFactory();
            TrelloConfiguration.RestClientProvider = new WebApiClientProvider();
            TrelloAuthorization.Default.AppKey = "MyAppKey";
            TrelloAuthorization.Default.UserToken = "MyUserToken";

            var board = new Board("7yuDFMwI");
            Debug.WriteLine(board);
        }
    }
}

Here are the details of the exception:

System.AggregateException occurred
HResult=0x80131500
Message=One or more errors occurred.
Source=Manatee.Trello
StackTrace:
at Manatee.Trello.Internal.ExceptionHandling.DebugLog.Error(Exception e, Boolean shouldThrow)
at Manatee.Trello.Internal.DataAccess.JsonRepository.ValidateResponse(IRestRequest request)
at Manatee.Trello.Internal.DataAccess.JsonRepository.Execute[T](TrelloAuthorization auth, Endpoint endpoint, IDictionary`2 parameters)
at Manatee.Trello.Internal.Synchronization.BoardContext.GetData()
at Manatee.Trello.Internal.Synchronization.SynchronizationContext`1.Merge()
at Manatee.Trello.Internal.Synchronization.SynchronizationContext.Synchronize(Boolean force)
at Manatee.Trello.Board.ToString()
at System.Diagnostics.TraceListener.WriteLine(Object o)
at System.Diagnostics.TraceInternal.WriteLine(Object value)
at System.Diagnostics.Debug.WriteLine(Object value)
at MspUpdate.Program.Main(String[] args) in C:\Users\Bruce Pike Rice\Documents\Source\a2\JiraInteraction\Program.cs:line 33

Inner Exception 1:
HttpRequestException: Trello reported an error: 'invalid token'

Thanks in advance for your attention.

BruceP

1

There are 1 answers

1
BruceP On

The problem was caused by an expired user token. Thanks to Greg Dennis for pointing this out.

To fix the problem

  1. Get a new developer API key from https://trello.com/app-key
  2. Get a new user token from https://trello.com/1/authorize?expiration=never&scope=read,write,account&response_type=token&name=Server%20Token&key=