We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
jasskcet
8 years agoExplorer | Level 3
Eroor 400 when using the Dropbox choose API
Hi,
I am trying to consume the Dropbox choose API as from the below link:
https://www.dropbox.com/developers/chooser
However, when the chooser window is shown, it ends up with error 400.
Kindly advise on what went wrong.
We do not currently include the MIME type in the response from metadata returned by the Chooser. I have filed this as a feature request for the Chooser.
In cases where the returned file name includes a file extension, is it possible to infer the MIME type from the file extension?
15 Replies
Replies have been turned off for this discussion
- Greg-DB8 years ago
Dropbox Community Moderator
[Cross-linking for reference: https://stackoverflow.com/questions/52756880/error-400-while-using-dropbox-chooser-api ]
Can you share the full URL of that page that's showing the 400 error? That would help us look into this. Thanks in advance!
- dolphin-newbie8 years agoExplorer | Level 3
Hi
I'm getting the same error, and here is the full URL
https://www.dropbox.com/chooser?origin=https%3A%2F%2Fhttp://a9b7088a.ngrok.io&app_key=0ro4ue0jd0uqghq&link_type=preview&trigger=button&multiselect=false&extensions=&folderselect=false&iframe=false&version=2 - Greg-DB8 years ago
Dropbox Community Moderator
dolphin-newbie It looks like the issue is that you don't have the domain you're running from pre-registered as a Dropbox Chooser/Saver domain on the app's page on the App Console. You need to pre-register the domain(s) you'll be using your app key on so that other people can't use your app key on their own sites.
In this case, you'd want to register 'a9b7088a.ngrok.io'. To do so, go to the App Console, click on the app with app key '0ro4ue0jd0uqghq', and enter 'a9b7088a.ngrok.io' under "Chooser/Saver domains".
- jasskcet8 years agoExplorer | Level 3
Greg,
Here is the URL
One more thing, currently I have embedded the code from the below link locally onto my application(Is it ok to do that?). We wouldn't be using HTML to embed the script.
https://www.dropbox.com/static/api/2/dropins.js
Hence is there any other way to pass the app key.
- Greg-DB8 years ago
Dropbox Community Moderator
jasskcet That URL isn't currently returning a 400 for me, so it sounds like you already managed to get that sorted out. (E.g., by registering the domain, like in my last comment.)
Also, we don't recommend copying and embedding your own copy of dropins.js, as then you won't get any updates we make to it.
Finally, it is technically possible to set the app key programmatically like this:
Dropbox.appKey = "APP_KEY";
That's not documented though, so it shouldn't be considered officially supported.
- dolphin-newbie8 years agoExplorer | Level 3
Thanks for the reply @Greg . I actually do have the server domain specified.
- Greg-DB8 years ago
Dropbox Community Moderator
dolphin-newbie Taking a closer look at the sample URL you shared, I see your 'origin' value is actually "https%3A%2F%2Fhttp://a9b7088a.ngrok.io", which decodes to "https://http://a9b7088a.ngrok.io".
That's not valid, as it contains two protocols (both "https://" and "http://") for some reason. Can you check that you have a valid URL with just one protocol for the page where you're hosting your Chooser integration?
- jasskcet8 years agoExplorer | Level 3
Greg-DB Yes i understand. I have one more question. After creation of an app and obtaining the App Key, we are using this app key in js. When the application is loaded in browser, the app key will be visible to the end user. Does this pose any threat or is this a security loophole since anyone would be able to use this app key.
Secondly, once I choose the document using chooser API, I am able to get the link from metadata of the document. If I need the data of the document as binary, how can I achieve this?.
- Greg-DB8 years ago
Dropbox Community Moderator
[Cross-linking for reference: https://stackoverflow.com/questions/52756880/error-400-while-using-dropbox-chooser-api?noredirect=1#comment92756867_52756880 ]
jasskcet No, app keys are not considered secret or sensitive, so it's acceptable (and necessary) to expose them to end-users. Use of your app key with the Dropbox Chooser/Saver is protected by the Chooser/Saver domain pre-registration requirement.
If you want to download the file content for the file selected in the Dropbox Chooser, you can do so by using the "direct" link type, and then downloading the content directly from the URL supplied in the "link" property returned in the response.
- jasskcet8 years agoExplorer | Level 3
Hi Greg,
Am able to see the link for download. The link will be something like this:
https://dl.dropboxusercontent.com/.....
However I need to read the content of this file as BLOB.
Is this possible using a http GET request or something?. Please let me know how to achieve this.
For instance: https://stackoverflow.com/questions/23684874/dropbox-chooser-get-content-of-the-file-in-javascript - outdated one though.
And when I checked this link https://www.dropboxforum.com/t5/API-Support-Feedback/Get-Access-Token-from-Chooser-API/td-p/269129, they have mentioned about GET, but am not able to do a successful get call using the link returned by chooser. ( Is it possible to simulate the GET in Chrome Postman? ). Also is there additional we need to pass for GET, for instance, access token or anything else?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!