API is returning "invalid/used nonce"
kounch
Registered Users Posts: 7 Beginner grinner
Hi,
I'm the developer of a Smugmug client on Android.
The app accesses Smugmug via v1.2.2 of the API, and uses OAuth.
Recently, my users have been receiving this error when requesting photo or albums lists via the smugmug.images.get and smugmug.albums.get methods :
{"stat":"fail","method":"smugmug.albums.get","code":33,"message":"invalid/used nonce"}
This is a recent issue that I can't reproduce myself. The nonce is generated from a static counter which is incremented for each request, so I don't think it is used already, specially for this timestamp and signature.
Is this a common problem, any idea how the nonce can be deemed invalid ?
Thanks for your help...
I'm the developer of a Smugmug client on Android.
The app accesses Smugmug via v1.2.2 of the API, and uses OAuth.
Recently, my users have been receiving this error when requesting photo or albums lists via the smugmug.images.get and smugmug.albums.get methods :
{"stat":"fail","method":"smugmug.albums.get","code":33,"message":"invalid/used nonce"}
This is a recent issue that I can't reproduce myself. The nonce is generated from a static counter which is incremented for each request, so I don't think it is used already, specially for this timestamp and signature.
Is this a common problem, any idea how the nonce can be deemed invalid ?
Thanks for your help...
0
Comments
If you are receiving that error message, your app has previously used the same token, timestamp, nonce combination (they are logged to the db). Instead of using an incremented counter, perhaps MD5'ng the timestamp along with some random salt might be a better option.
Cheers,
David
SmugMug API Developer
My Photos
- static incremented counter (the counter was incremented in an atomic way, so it should have been unique for the timestamp and token...)
- a hascode of the timestamp in milliseconds : this one had a small probability of being used twice
The two methods have very little probabilities of creating duplicate combinations of timestamp+nonce+token, so I'm really suspecting that the API is returning a wrong error message (and something else prevented the auth) or that something is wrong with the verification of the combination nonce+timestamp+token...
Would you be ok to take a deeper look ? the fact that this only happens in a small proportion of requests makes me think this is not an issue with the way I sign requests...
cheers
Greg
Sorry, it's not an api bug...the error message that you are receiving is only thrown in one spot, after specifically checking if the token, timestamp, nonce combination already exists in the DB.
If it was a bug, reports of this issue would be pretty widespread, since we have quite a few apps and services using our OAuth implementation.
Cheers,
David
SmugMug API Developer
My Photos
This is very weird, but I'll have to deal with it.
I'll try the random nonce then, instead of my static counter...
So all good on the API side, all my fault
cheers
Greg