You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
milesmajefski
7 years agoNew member | Level 2
Accessing get_metadata endpoint without Dropbox Javascript package
For fun, I'm making a cataloging web app using asp.net core 2.1 MVC and javascript. I don't need a frontend framework, so I don't want to bring in the whole NodeJS npm situation into this project. ...
- 7 years ago
While we recommend using the official libraries, it's not required. You can always call the Dropbox API HTTPS endpoints directly if you prefer. The documentation covers the requirements for each endpoint, and includes an example of calling using curl, e.g., for /2/files/get_metadata.
It looks like you're running in to a CORS issue though, due to your use of `credentials: 'include'`. Dropbox API calls, such as for /2/files/get_metadata, are authenticated using Dropbox API access tokens, not the browser's credentials. You need to supply the access token in the "Authorization" header as a "Bearer" token. (Also, the parameters should be a JSON string in the body.)
So, you code should look more like this:
fetch(apiURL, { method: 'post', headers: { "Authorization": "Bearer ACCESS_TOKEN_HERE", "Content-type": "application/json; charset=UTF-8" }, body: JSON.stringify(reqData), })
Greg-DB
7 years agoDropbox Staff
While we recommend using the official libraries, it's not required. You can always call the Dropbox API HTTPS endpoints directly if you prefer. The documentation covers the requirements for each endpoint, and includes an example of calling using curl, e.g., for /2/files/get_metadata.
It looks like you're running in to a CORS issue though, due to your use of `credentials: 'include'`. Dropbox API calls, such as for /2/files/get_metadata, are authenticated using Dropbox API access tokens, not the browser's credentials. You need to supply the access token in the "Authorization" header as a "Bearer" token. (Also, the parameters should be a JSON string in the body.)
So, you code should look more like this:
fetch(apiURL, { method: 'post', headers: { "Authorization": "Bearer ACCESS_TOKEN_HERE", "Content-type": "application/json; charset=UTF-8" }, body: JSON.stringify(reqData), })
- milesmajefski7 years agoNew member | Level 2
Thank You! I see that when I make the body parameter a string and make the other changes concerning Authorization, it works. However I am using the the Access Token that I made manually for my own development purposes. My new problem is about getting the access token on the server side. I'll post another question after I have thought about everything some more. :slight_smile:
- Greg-DB7 years agoDropbox Staff
Great! I'm glad to hear you were able to get that working.
For information on the OAuth app authorization flow, I recommend reviewing the OAuth guide and the authorization documentation.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,887 PostsLatest Activity: 29 seconds agoIf 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 or Facebook.
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!