Most developers use the Dropbox Core API through one of many existing SDKs, including third-party libraries supported by the community. But there's often something to be learned by peeling back a layer of abstraction and looking at what's underneath. In the case of the Core API, what's underneath is a simple web API built on HTTP, OAuth 2.0, and JSON.
Last month, I published a blog post about how to use OAuth 2.0 with the Core API. In that post, I used
curl to show you the raw HTTP requests involved in authorizing an app and then making calls to the API. I've recently published a project on GitHub called " OAuth 2 the Hard Way," which goes a step further and shows full working examples of web apps in a variety of languages. Each example demonstrates the following functionality:
- Running a web server.
- Redirecting the user to authenticate with Dropbox.
- Acquiring an access token to make API calls on behalf of the user.
- Making a simple API call to get the user's account info.
I used friendly web frameworks (like Sinatra and Flask) where possible but avoided the use of any OAuth or Dropbox libraries. My goal was to keep each example as simple as possible while still showing exactly how the interaction with the Dropbox API works.