Note that there are some explanatory texts on larger screens.

plurals
  1. PONodeJS, Express server with ssl to use Dropbox API - 400 Bad Request
    text
    copied!<p>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. </p> <p>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:</p> <pre><code>var options = { key: fs.readFileSync('./cred/ssl.key'), cert: fs.readFileSync('./cred/ssl.crt'), ca: [fs.readFileSync('./cred/sub.class1.server.ca.pem')] } </code></pre> <p>And my server looks like:</p> <pre><code>https.createServer(options,app).listen(443, function(){ console.log('Express server listening on port ' + 443); }); </code></pre> <p>When I try authenticating I use the built-in dropbox javascript client and call:</p> <pre><code>var server = new Dropbox.AuthDriver.NodeServer(500); </code></pre> <p>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:</p> <pre><code>curl https://www.dropbox.com/1/oauth2/authorize?client_id={client_id}&amp;redirect_uri=https%3A%2F%2Fsimplestever.com%3A8912%2Foauth_callback/&amp;response_type=code/&amp;state={state} </code></pre> <p>And I get this as a response (forgive the formatting): <h1>Error (400)</h1> 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. <br/><br/><br/> More details for developers <code>Missing &#34;response_type&#34;.</code></p> </p> <p>===================== 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!</p> <p>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. </p> <p>Edit2: I ended up writing the authentication request using the request module and it worked! Just in the nick of time. Cheers!</p> <p>Edit3: I should give credit to the code I imitated. <a href="https://github.com/smarx/othw/blob/master/Node.js/app.js" rel="nofollow">https://github.com/smarx/othw/blob/master/Node.js/app.js</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload