I am investigating using the services module in Drupal 6 to get data from some custom views in JSON format. I followed an article at http://drupal.org/node/308629 and created a vb version of this project (pushed up to https://sharpred@github.com/sharpred/ConsoleApplicationDrupal.git)
The first time I run my code I get "Invalid API Key", subsequent runs return "token has been used previously for a request. Re-try with another nonce key". The second error is a bit spurious IMO as my code creates a new random nonce each time it is run.
I also noticed that the first run creates an entry in services_timestamp_nonce table that contains just the timestamp but no nonce or domain value. If I delete this record, it goes back to the "invalid api key" message.
The code works unauthenticated and the method call from /admin/build/services/browse/views.get on the site works also.
Any ideas as to why this does not work?
Searching google, the most common source of "invalid api key" seems to be either the timestamp one uses is wrong or the api key does not match the domain used in creating the hash. Neither are true in my case as far as I can see. I created a gist of my code used to create the timestamp and hash at https://gist.github.com/1151222
Can anyone help on getting this process to work?
I figured this out after trawling through the code for the services module. Some of the values in my multipart form were not enclosed with quotes, so were being processed as nulls by the services_key_auth module. This meant that on the first pass, only the timestamp was being written to the nonce table and the computed hash did not match my hash because of the quotes. On subsequent updates, the module was effectively doing a search for a nonce value of null and on finding one in the database, returning the result that one had been used before. If anyone else gets this issue, pull my github project linked above and look at my code.