ForumsDevelopersGetting "Invalid Key" Error when Key is Correct


Getting "Invalid Key" Error when Key is Correct
Author Message
dnicholson

Posted: May 30, 2011
Score: 0 Reference
We are migrating to version 2 of the API and, on rare occasions, we are seeing the following odd behavior:

At the end of a 4 hour time slot our application requests a new token and receives it without problems. The token is used to generate a new key.

Immediately after generating the new key, our application attempts to retrieve account information. The attempt fails due to receiving an "Invalid Key" error from Toodledo's server. The scheduled sync is aborted.

One hour later, at the next scheduled sync, our application tries again to get account information using the exact same key. This time it succeeds. All remaining API calls for the scheduled sync have no issues.

Using the online tool in the API documentation, I have double-checked to make sure that our application is generating the correct key.

Nothing is changing at the Toodledo account during this time. The password is the same.

The problem only occurs right after a new token is obtained. It has not happened in the middle of the 4 hour time slot.

Any ideas what could cause the Toodledo server to reject a key at one point and then accept the same key an hour later?
Jake

Toodledo Founder
Posted: May 31, 2011
Score: 0 Reference
Im not really sure what could cause this. I suppose it could be a timing issue. If your app is really really fast it could try to use the new token before that token has replicated to all of our database servers. Can you try an experiment? Put a 2 second delay in between getting a token, and using it. If that fixes the problem then let me know and I'll see if we can get around this on our end by having token validation use the master db instead of the replicas.
dnicholson

Posted: May 31, 2011
Score: 0 Reference
I've adjusted the software to delay for 2 seconds after receiving an "Invalid Key" error, and then try again. If the second attempt succeeds, then we will know that your theory about the database updates is correct. This problem doesn't happen very often, so it may take a few days to see if this is the case. I'll let you know.
dnicholson

Posted: Jun 09, 2011
Score: 0 Reference
I have managed to log some occurrences of the problem, and it looks like your theory about the database updates may be correct.

Each time, our app receives the "Invalid Key" error and then pauses for 2 seconds and tries the same request again. On the second attempt, no error occurs and the sync runs normally.
Jake

Toodledo Founder
Posted: Jun 09, 2011
Score: 0 Reference
Thanks for experimenting. We will look into getting this fixed on our end.
You cannot reply yet

U Back to topic home

R Post a reply

To participate in these forums, you must be signed in.