Invalid signature during upload

Feb 16, 2011 at 5:06 PM

I'm working through your examples, and can't get the upload file to work.  I have the engine initialized properly, and have successfully executed the GetAccountInfo, Download, CreateDirectory, but can't upload.

I get the error:

{"error": "Invalid signature. Expected signature base string: POST&http%3A%2F%2Fapi-content.dropbox.com%2F0%2Ffiles%2Fdropbox&file%3Dnewtxt.txt%26oauth_consumer_key%xxxxxxxxxxxxxxxxxxx%26oauth_nonce%3D9577572%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1297879374%26oauth_token%3Dq9vttui2tl4y19q%26oauth_version%3D1.0"}

Any ideas?

Chuck

Feb 16, 2011 at 5:20 PM

Ok, got it to work if I replace the path parameter (string.Empty) with an actual path.

Coordinator
Feb 16, 2011 at 5:23 PM

Hi,

 

In case you are using latest version of sources - not release one, emtpy string on upload - means upload to root folder

Feb 16, 2011 at 8:08 PM

Thanks -- that fixed it!

Chuck

Feb 22, 2011 at 10:36 PM

Same problem.  Able to login OK, but get "Unauthorized" exception when I try to upload.  Tried with string.Empty and "/Public" as first parameter to UploadFile.

A question on the statement:  engine.SetToken("usertoken", "usersecret");

What should the '"usertoken" and "usersecret" values be?  I have tried to set them to the same values as ApiKey and ApiSecret, but this did not work either.

 

 

Feb 22, 2011 at 10:55 PM
Edited Feb 22, 2011 at 10:59 PM

Whenever you log in, the callback method will receive a new UserInfo object.  There is a .Secret and .Token value that you need to save.  These are the values that allow you to use your dropbox without having to login again (and not have to save the user's password).

 To upload, try the following example:

DropBoxyEngine engine = new DropBoxy.DropBoxyEngine();
engine.ApiKey = apiKey; 
engine.ApiSecret = apiSecret;
engine.SetToken(token, secret); -- here are the values saved after login

Action<bool> callback = UploadCompleted;
engine.UploadFile(path, uploadFileName, buffer, callback);

Chuck

Feb 23, 2011 at 5:40 AM

Thanks a lot Chuck,

Yes, thats the ticket.  Managed to upload a file successfully, but was so disappointed when I looked at the content to see that it was not what I sent up.  Only three bytes of content - Hex 20, 03, 02. 

Now where did I see that pattern before?  Oh yes, that wierd byte array in the UploadFile function call is my file content, and parameter two is just the file name and not the content.

Anyway, when I packaged up a byte array of my file content, and used it as parameter three in the UploadFile call, I ended up with my file properly uploaded to DropBox. 

Thanks again.

 

Feb 23, 2011 at 7:08 AM

That's funny!  I went through the same pain...