0

I'm currently at y-hack, hacking up an app. I've never deployed an app to a server before, but I've managed to create an AWS EC2 instance, I created ca certificates with startssl, and now I'm trying to retrieve information using the DropBox API.

My code works on my local machine just fine, but I keep getting a 400 Bad Request Error when I try to use the code on my server. Here's what my options look like:

var options = {
    key: fs.readFileSync('./cred/ssl.key'),
    cert: fs.readFileSync('./cred/ssl.crt'),
    ca: [fs.readFileSync('./cred/sub.class1.server.ca.pem')]
}

And my server looks like:

https.createServer(options,app).listen(443, function(){
  console.log('Express server listening on port ' + 443);
});

When I try authenticating I use the built-in dropbox javascript client and call:

var server = new Dropbox.AuthDriver.NodeServer(500);

All my ports are open and I'm able to access my website with HTTPS. I've verified that my SSL certificate is okay, but every time I make a request from my micro instance to DropBox, the page hangs. I tried:

curl https://www.dropbox.com/1/oauth2/authorize?client_id={client_id}&redirect_uri=https%3A%2F%2Fsimplestever.com%3A8912%2Foauth_callback/&response_type=code/&state={state}

And I get this as a response (forgive the formatting):

Error (400)

It seems the app you were using submitted a bad request. If you would like to report this error to the app's developer, include the information below.


More details for developers Missing "response_type".

===================== I'm very new to this all and only taught myself today. I never used curl before... If anyone has any idea why I'm having these issues with the request, it would be incredibly helpful! Cheers!

Edit: I curled with the escaped characters and it worked! ...which means the client may be broken? I'll replace it with a query and forget about the csrf variable for now to see if it works.

Edit2: I ended up writing the authentication request using the request module and it worked! Just in the nick of time. Cheers!

Edit3: I should give credit to the code I imitated. https://github.com/smarx/othw/blob/master/Node.js/app.js

4

1 回答 1

0

I think the issue with your curl command is that it has unescaped ampersands. Try putting quotes around the whole URL.

于 2013-11-09T18:55:50.197 回答